|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/ `: w8 c" [& ?
% R& Z' M2 q; G( Z% G0 |- G$ M. z3 oNX二次开发源码分享: 使用NXOpen获取对象最小距离
, o+ Q- ^- I4 j0 R7 Z& n6 m& w4 |6 y9 K! }# X
8 V- a$ n9 ~0 @' E[mw_shl_code=csharp,true]
. C/ g) q. E1 W0 @ Dim theSession As Session = Session.GetSession()
, @' C0 \( B% ` Dim workPart As Part = theSession.Parts.Work. S/ X, [' }+ _4 }: [ i1 h
* Q# H0 J* T9 g
Dim object1 As DisplayableObject = SelectAnObject("First Object")7 e: n' o! [2 C; i9 ^6 E
Dim object2 As DisplayableObject = SelectAnObject("Second Object")
+ b/ a' c5 q* c. X9 J- \3 H1 f0 F+ ]7 R v8 U" Q2 C% J( j
' either obtain Unit as desired or use default (null) unit* K0 R- N4 B) l: \
Dim unitMM As Unit = CType(workPart.UniTCollection.FindObject("MilliMeter"), Unit)
. T& O/ a5 L0 _9 A8 K' I7 q Dim nullUnit As Unit = Nothing
+ @( U5 K# W: x" h' o4 W Dim measureDistance1 As MeasureDistance) e9 {$ `& t* C! I, X
5 z8 _# h) {& U; z/ Z measureDistance1 = workPart.MeasureManager.NewDistance(nullUnit, _
7 y9 v+ B! g% a! v- { MeasureManager.MeasureType.Minimum, object1, object2)
; A+ _, p" M \' i( R
' B: l( ^2 P1 \1 _. Q- J9 G Dim theLW As ListingWindow = theSession.ListingWindow! |. Z9 M1 |6 v, J
theLW.Open()( i$ B/ k/ }9 ] {+ d
theLW.WriteLine("Minimum distance = " & measureDistance1.Value.ToString("F6"))* p( }6 j `6 b
5 g% n M$ }$ e& z8 {$ I$ n
' optionally, create Distance Measurement feature (needs solid_modeling)" T. o/ \( g1 d: R3 ~6 u6 e/ ]
' Dim measure1 As NXOpen.Measure = measureDistance1.CreateFeature()
$ J" ]& I, {5 h# B0 Z1 b$ B: X( \+ u measureDistance1.Dispose()[/mw_shl_code]# ]4 [1 A* L0 F
|
|