|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
4 M5 f9 b. \; N9 I: S' c7 n
( W/ g! l" W4 {% A" `7 hNX二次开发源码分享: 使用NXOpen获取对象最小距离 o: A3 D5 u# T& `1 S \: K% X
( _2 M: r* E+ ~1 y) m2 L
, r$ e4 l& N5 {$ p[mw_shl_code=csharp,true]9 r) L% [2 ]0 Q( H
Dim theSession As Session = Session.GetSession(): W" I) Q$ e2 h! x- S
Dim workPart As Part = theSession.Parts.Work; @6 Z* {( o ]& E' b z$ w# e
! r* b7 M Q; K0 k' Z
Dim object1 As DisplayableObject = SelectAnObject("First Object")3 b! W# `) ~3 p m7 t
Dim object2 As DisplayableObject = SelectAnObject("Second Object")
+ F" `' `) d3 Z9 S$ H4 A5 u9 H" b8 o" A/ D5 P1 T
' either obtain Unit as desired or use default (null) unit
2 `+ W! E# v3 j4 x; Y5 K% Q+ ~ Dim unitMM As Unit = CType(workPart.UniTCollection.FindObject("MilliMeter"), Unit)' I7 W: f0 V$ k7 f& E
Dim nullUnit As Unit = Nothing
$ Y8 v9 @4 w& Z+ I Dim measureDistance1 As MeasureDistance* D8 [" q8 O& i1 m& Y8 `( w
( F: [' g& b% X8 z: a measureDistance1 = workPart.MeasureManager.NewDistance(nullUnit, _9 E* K; a0 K, ?& Z0 m
MeasureManager.MeasureType.Minimum, object1, object2): y+ p3 Q+ c: u2 n. m
; s6 `! X O2 P! |! w
Dim theLW As ListingWindow = theSession.ListingWindow' w; L f2 D, S$ g1 i: h0 l( W
theLW.Open()
/ O1 L0 Z' ]; E: T theLW.WriteLine("Minimum distance = " & measureDistance1.Value.ToString("F6"))2 N) X4 }- F& i7 W& B# O# ~
; J3 i' p# S" [. [# ` ' optionally, create Distance Measurement feature (needs solid_modeling)
" ^( A( p0 J- i& O4 O ' Dim measure1 As NXOpen.Measure = measureDistance1.CreateFeature()/ | a# O9 s0 d% U; s& C
measureDistance1.Dispose()[/mw_shl_code]
, L, d; k5 y+ e% S( B |
|