|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/ G# L! l8 d/ M( t8 A9 }0 @& T, c
+ D9 V) Y) U+ E9 _5 l+ gNX二次开发源码分享: 使用NXOpen获取对象最小距离
; w$ U7 B; p& S1 `) a# g$ N- c& e, d' G& d( p. m
7 \! ~, t3 `0 L& _" o: M9 \9 P[mw_shl_code=csharp,true]
# G( r5 N1 E1 ?/ J, Q1 c" @ Dim theSession As Session = Session.GetSession()8 \! h% b( k# O. T1 @
Dim workPart As Part = theSession.Parts.Work
0 Y% r; C; u/ f% V2 q) }+ o; d9 u# L: e/ s$ g' C
Dim object1 As DisplayableObject = SelectAnObject("First Object")
/ J! L4 X& p: d; {: e; h Dim object2 As DisplayableObject = SelectAnObject("Second Object")
8 s* p/ N6 d1 O, j1 l( X0 F( }, J4 x: _( P9 s
' either obtain Unit as desired or use default (null) unit9 a1 i0 ^+ j' r* v4 e
Dim unitMM As Unit = CType(workPart.UniTCollection.FindObject("MilliMeter"), Unit)2 E: o" b* l) w
Dim nullUnit As Unit = Nothing
/ V$ x5 L) s' [& [# z! b Dim measureDistance1 As MeasureDistance0 [- ~( j# i7 y; Q4 }
0 j" P; L6 o) {0 h# U) p* T
measureDistance1 = workPart.MeasureManager.NewDistance(nullUnit, _* O) ~2 ]: q7 N7 E- u. c
MeasureManager.MeasureType.Minimum, object1, object2)7 x+ o+ D) S5 k+ T1 {, i
# i% ?+ b6 \9 y$ M- c4 [7 w% } Dim theLW As ListingWindow = theSession.ListingWindow1 P) ^' ~) w' G! \. b5 f, M
theLW.Open()
( T) q, n% q9 l2 z theLW.WriteLine("Minimum distance = " & measureDistance1.Value.ToString("F6"))
; i. I( l3 b$ [! I/ A
% I' _8 N1 v1 g& F ' optionally, create Distance Measurement feature (needs solid_modeling)
4 c; ?: d) E i ' Dim measure1 As NXOpen.Measure = measureDistance1.CreateFeature(): Z$ {: S7 v* A Q5 B% ?+ m
measureDistance1.Dispose()[/mw_shl_code]
W+ ] {' ^; W. W) I3 } |
|