|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 M1 h1 P8 q) A7 `+ k& u$ P% d
6 e$ L9 o8 d) [* o0 H. rNX二次开发源码分享: 使用NXOpen获取对象最小距离
7 @8 u2 U& @6 Z1 u5 Z, [. g; Z$ q/ e$ I) d) J: \
+ d, ~1 Z/ N0 [1 C: m[mw_shl_code=csharp,true]: r6 p2 o) y' _. a
Dim theSession As Session = Session.GetSession(), n" C" ^" g: |3 n9 V
Dim workPart As Part = theSession.Parts.Work
2 w! C1 i- V. V2 c% [0 x
" s x$ Z& s) F( v Dim object1 As DisplayableObject = SelectAnObject("First Object")( e3 P) T" e3 W) e
Dim object2 As DisplayableObject = SelectAnObject("Second Object")
+ j3 L& ]; \* k. k2 T
- O5 G3 T( o! k ' either obtain Unit as desired or use default (null) unit. Q7 D7 z) ~" m% A9 ~' l
Dim unitMM As Unit = CType(workPart.UniTCollection.FindObject("MilliMeter"), Unit)0 Q6 d2 L; J/ h! E; d
Dim nullUnit As Unit = Nothing5 e* j6 I/ J$ Z3 Q& e+ D
Dim measureDistance1 As MeasureDistance5 S/ T* c5 O+ P Q! E* ]2 v
( M5 b% i" k( o9 H( z5 f
measureDistance1 = workPart.MeasureManager.NewDistance(nullUnit, _
0 ^* d8 J9 w; G8 p( z" T MeasureManager.MeasureType.Minimum, object1, object2)' f/ i6 ?1 b5 `; }8 t
! @1 C8 B- v8 h% \* B( J: ? Dim theLW As ListingWindow = theSession.ListingWindow
+ {0 F& g1 F8 n8 m theLW.Open()
% @/ K W3 v* G' d4 Q. Z7 I theLW.WriteLine("Minimum distance = " & measureDistance1.Value.ToString("F6"))( b. j& m. S/ [5 p. y! E. J/ z3 ^
1 r2 Z6 {9 t; K% F" [1 \
' optionally, create Distance Measurement feature (needs solid_modeling)# |& P+ v; r- p( l5 {: f% { O
' Dim measure1 As NXOpen.Measure = measureDistance1.CreateFeature()
: A; M) `! }7 G/ G+ A5 E4 i measureDistance1.Dispose()[/mw_shl_code]3 E0 t5 [) s% y: @% U2 H' k
|
|