|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
. }1 N: k) u/ \4 ^' m L2 R
NX二次开发源码分享:测量两个对象之间最短距离
3 z0 M' h! w* F1 m. B; K$ Q' v2 \3 q) g5 ^) e! p9 f) `- n; W+ b& P+ L
[mw_shl_code=csharp,true] Dim theSession As Session = Session.GetSession()
! h1 k1 r2 \6 y! l$ g2 `5 _ Dim workPart As Part = theSession.Parts.Work
; |7 W i, G a% J! m
1 B# x; l2 d$ h0 G% w! J Dim object1 As DisplayableObject = SelectAnObject("First Object")
+ t; `4 b5 `* C5 F Dim object2 As DisplayableObject = SelectAnObject("Second Object")3 k) A# |1 f( T7 n+ n
) ?3 G6 p3 X3 K5 e- m+ f$ j6 B* e+ m' H) y
Dim unitMM As Unit = CType(workPart.UniTCollection.FindObject("MilliMeter"), Unit)0 Y$ P2 M! y% m7 o6 E
Dim nullUnit As Unit = Nothing
1 _! w; p8 g2 t# d! L2 ^ Dim measureDistance1 As MeasureDistance
9 |8 d& r! l5 t0 }1 Y/ Z
0 h* u9 u8 F7 s/ N4 Z measureDistance1 = workPart.MeasureManager.NewDistance(nullUnit,8 {- k. J/ A* [
MeasureManager.MeasureType.Maximum, object1, object2)
- q- J% i0 B& d t5 H( Z7 F% E* U$ m
Dim theLW As ListingWindow = theSession.ListingWindow# ]% R- p: u P i0 t- y3 d
theLW.Open()
) S& h/ X6 V0 `# [ theLW.WriteLine("Maximum distance = " & measureDistance1.Value.ToString("F6"))3 U+ B" y' o; ^( _! P
8 |2 J% x1 { M7 j1 S
% v3 _% F5 `' r/ V measureDistance1.Dispose()[/mw_shl_code]& P% D+ c7 E: ]+ S; r' G# G6 A* w
|
|