|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 b6 ]2 _' f' q% h* s' o. Q' t! W
. ~1 [& U& n k* I |5 lNX二次开发源码分享: 使用NXOpen获取对象最小距离$ s7 t) P8 |) c0 I' c/ i
6 d1 e9 H* _9 y2 G
( Z7 n- v4 n5 [- M
[mw_shl_code=csharp,true]8 f: ], h# w1 @$ f* t1 A) \6 J
Dim theSession As Session = Session.GetSession()
; W: l2 @% y+ U+ d6 c Dim workPart As Part = theSession.Parts.Work1 E* U3 f5 b" t& b3 K; Z* v/ Z
% v; {9 d% E' ]) X3 Z3 a Dim object1 As DisplayableObject = SelectAnObject("First Object")9 {) g# j, J# a# G5 C
Dim object2 As DisplayableObject = SelectAnObject("Second Object")7 t/ I/ {; p; Z* Q% @0 B
) e. P3 H) L2 R3 Y1 |9 x5 q* _ ' either obtain Unit as desired or use default (null) unit
- }/ Z) r* r" U1 Y+ }& R Dim unitMM As Unit = CType(workPart.UniTCollection.FindObject("MilliMeter"), Unit)
5 g5 d, w2 M: o. G* x& C7 |1 d Dim nullUnit As Unit = Nothing+ r r' {4 L! b$ h }* y
Dim measureDistance1 As MeasureDistance* |4 k. w8 F% t$ d- y
% T" A* q. e7 `% Q! a0 A1 p# c
measureDistance1 = workPart.MeasureManager.NewDistance(nullUnit, _. r- Y8 j8 g4 w
MeasureManager.MeasureType.Minimum, object1, object2)( c+ B- x' K/ ^7 g% A
& v1 X p+ c/ H/ [6 R$ g; T Dim theLW As ListingWindow = theSession.ListingWindow, J9 A& n9 _7 n6 P- f% Z g
theLW.Open()
" p3 K4 z7 ^! _5 y6 Y. A theLW.WriteLine("Minimum distance = " & measureDistance1.Value.ToString("F6"))2 n6 Z& u' \& x$ T4 o, \3 \7 K" s
9 V4 L6 B9 w9 m, O" [3 Q% ~4 _$ M ' optionally, create Distance Measurement feature (needs solid_modeling)! v6 u! ]8 _/ p3 i8 [. ^( S3 v5 W9 O
' Dim measure1 As NXOpen.Measure = measureDistance1.CreateFeature()
# b) c0 E5 ~+ Q" c9 f1 o" v3 W measureDistance1.Dispose()[/mw_shl_code]
, X$ w) K a8 d! T3 h( I. b8 ~ |
|