|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
$ @, q* A' [5 W
" s v% w( h" p) T
NX二次开发源码分享: 使用NXOpen获取对象最小距离! i# g5 T" H, \1 Q3 ~! Y
2 p w( ~' p5 W: Q" Q$ l( N& b+ J0 |
]0 E8 P0 N2 V5 _" V7 T; k- M[mw_shl_code=csharp,true] ?% A+ r) T1 R/ I @
Dim theSession As Session = Session.GetSession()0 f: g2 m9 k# r3 _
Dim workPart As Part = theSession.Parts.Work
R" E! o# ]/ n
9 H' ~" m( U. R2 Y Dim object1 As DisplayableObject = SelectAnObject("First Object"), @+ u/ J# X$ M5 u! Q" O
Dim object2 As DisplayableObject = SelectAnObject("Second Object")
# r2 f! s! A$ G/ D" Z
6 [ _ q/ O$ E- K( U8 U$ J ' either obtain Unit as desired or use default (null) unit9 Z& v2 q: q1 o
Dim unitMM As Unit = CType(workPart.UniTCollection.FindObject("MilliMeter"), Unit)
5 c3 T$ ~: d/ s ^3 c: c Dim nullUnit As Unit = Nothing
- z0 Y" |, I8 f Dim measureDistance1 As MeasureDistance1 F7 n1 N0 s& O Z1 {% \; s' G
% B& {9 @ b* k$ D
measureDistance1 = workPart.MeasureManager.NewDistance(nullUnit, _
) l- u1 L. Z4 D' n$ X6 f4 I% n' D8 ] MeasureManager.MeasureType.Minimum, object1, object2)
3 y j6 ]5 o/ x* B% K. g0 T
3 {: \% p# J5 j( ?2 h; v# t7 U Q Dim theLW As ListingWindow = theSession.ListingWindow
; Y; E E* _4 O& r \ theLW.Open()% v* n D8 J# U' }: O g' r
theLW.WriteLine("Minimum distance = " & measureDistance1.Value.ToString("F6"))# t- Y: e1 N* P2 `/ m
1 c& p; |# P1 L6 r( A
' optionally, create Distance Measurement feature (needs solid_modeling)2 u; E1 U4 D, C1 C1 j
' Dim measure1 As NXOpen.Measure = measureDistance1.CreateFeature()" S9 H: R2 S1 D; s$ P! a0 M( |! i
measureDistance1.Dispose()[/mw_shl_code]
2 t& U" i% T x' K/ ?" ~ |
|