|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
0 F3 B2 T7 c r6 p* B" n& y1 J( m$ c. V& z( R$ f
NX二次开发源码分享: 使用NXOpen获取对象最小距离
% X% s, v! E# P) |+ E$ m
3 a. m5 N" k' D( Y: t9 t# ? V4 `! |8 }* Q( h, C" E, n3 d& L# ~4 R
[mw_shl_code=csharp,true]/ A) n9 w6 d2 G/ ^1 ]" q7 M6 K
Dim theSession As Session = Session.GetSession()6 W: V, [3 w# Q- D( j& K
Dim workPart As Part = theSession.Parts.Work
; w7 s' r$ L2 I% m' `4 q \0 ?+ _* |- p8 }4 K2 ^6 c4 Z
Dim object1 As DisplayableObject = SelectAnObject("First Object")
) \& F0 e4 A$ d2 [2 _* e1 o Dim object2 As DisplayableObject = SelectAnObject("Second Object")
# n/ M3 a% {9 j* p2 v+ X* q# i8 _) Y
' either obtain Unit as desired or use default (null) unit
8 b/ W- E$ ?' u/ B- f: q: q( b Dim unitMM As Unit = CType(workPart.UniTCollection.FindObject("MilliMeter"), Unit)3 C8 l! r `. k7 Q4 y
Dim nullUnit As Unit = Nothing
; l9 N+ J B( U) W0 O2 L5 T& G Dim measureDistance1 As MeasureDistance
# A/ f# ^3 R. Q* b6 }8 ^& ^ X6 l% b: E5 q
measureDistance1 = workPart.MeasureManager.NewDistance(nullUnit, _
* Z6 I1 A; ~0 ^7 R3 Y% n MeasureManager.MeasureType.Minimum, object1, object2), b& n1 P; n2 m8 j, e
( E$ L- M# n9 J8 i& h6 J Dim theLW As ListingWindow = theSession.ListingWindow
: E# C& J% |) o- C theLW.Open()
& C# ?0 Z+ U- [, ~6 ], c theLW.WriteLine("Minimum distance = " & measureDistance1.Value.ToString("F6"))3 @. h& ?$ W1 l. l* W& V
4 X$ O6 E* U( I ' optionally, create Distance Measurement feature (needs solid_modeling)* u/ B5 z' K# P. `& \
' Dim measure1 As NXOpen.Measure = measureDistance1.CreateFeature()
/ ]) T6 H0 t! D+ s+ [ measureDistance1.Dispose()[/mw_shl_code]
' z& _8 u( Y3 E# }/ m |
|