admin 发表于 2018-10-28 11:21:46

NX二次开发源码分享: 使用NXOpen获取对象最小距离



NX二次开发源码分享: 使用NXOpen获取对象最小距离



Dim theSession As Session = Session.GetSession()
      Dim workPart As Part = theSession.Parts.Work

      Dim object1 As DisplayableObject = SelectAnObject("First Object")
      Dim object2 As DisplayableObject = SelectAnObject("Second Object")

      ' either obtain Unit as desired or use default (null) unit
      Dim unitMM As Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), Unit)
      Dim nullUnit As Unit = Nothing
      Dim measureDistance1 As MeasureDistance

      measureDistance1 = workPart.MeasureManager.NewDistance(nullUnit, _
            MeasureManager.MeasureType.Minimum, object1, object2)

      Dim theLW As ListingWindow = theSession.ListingWindow
      theLW.Open()
      theLW.WriteLine("Minimum distance = " & measureDistance1.Value.ToString("F6"))

      ' optionally, create Distance Measurement feature (needs solid_modeling)
      ' Dim measure1 As NXOpen.Measure = measureDistance1.CreateFeature()
      measureDistance1.Dispose()
页: [1]
查看完整版本: NX二次开发源码分享: 使用NXOpen获取对象最小距离