|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
6 |: H8 q0 {1 u* _# R: H3 m
, n& }: @" _% S {NX二次开发源码分享: 使用NXOpen获取对象最小距离
, B. x# l; d, m1 p: X" j v9 ]7 u* ?' f- n
; X& O) M7 c% m: ?, C[mw_shl_code=csharp,true]
, b5 |: j! l' X Dim theSession As Session = Session.GetSession()6 S! z V$ f" `$ G! V; e
Dim workPart As Part = theSession.Parts.Work% I& v! o$ |' n' h# Z8 X4 h. c
^' I+ o: z) @( Y! h& k/ P
Dim object1 As DisplayableObject = SelectAnObject("First Object")2 v, O$ |9 h5 _* w Y, i. }
Dim object2 As DisplayableObject = SelectAnObject("Second Object")6 R' D9 _" O. n1 F- ^$ F! S1 M, y
& s$ l1 Q! T- P( z8 b$ S ' either obtain Unit as desired or use default (null) unit
/ p( C: V, [2 L Dim unitMM As Unit = CType(workPart.UniTCollection.FindObject("MilliMeter"), Unit) Q1 `7 b& a9 u* }* W- {
Dim nullUnit As Unit = Nothing
9 l7 U( J) Z+ v2 o4 { Dim measureDistance1 As MeasureDistance
" @5 W$ b6 o* }' Y9 f% H, b' v; Z0 X9 J
measureDistance1 = workPart.MeasureManager.NewDistance(nullUnit, _
8 E' r9 d, q% P$ G- n MeasureManager.MeasureType.Minimum, object1, object2)
5 Y$ t: m" T M7 T2 y. u0 a$ Z0 @- k* W. T7 R7 Q! w. q" X) @
Dim theLW As ListingWindow = theSession.ListingWindow% u& ]' h J8 P( S- H
theLW.Open()
4 R0 p8 ?2 u6 ]" H: P theLW.WriteLine("Minimum distance = " & measureDistance1.Value.ToString("F6"))
' x8 {9 V* S& b- l9 j% ] _+ S# K, x4 |% `* t
' optionally, create Distance Measurement feature (needs solid_modeling)
' }4 E3 @2 @: R( Y' W1 r ' Dim measure1 As NXOpen.Measure = measureDistance1.CreateFeature()% y7 m1 B4 w" d6 m6 u/ u
measureDistance1.Dispose()[/mw_shl_code]" {" J) J ?. M, ~
|
|