你的粉 发表于 2018-6-2 14:23:40

怎麼獲得點集內點的坐標

您可以遍歷集合來處理每個特徵或查找特定的特徵。
Option Strict Off
Imports System
Imports NXOpen

Module Module1

    Sub Main()

      Dim theSession As Session = Session.GetSession()
      If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
      End If

      Dim workPart As Part = theSession.Parts.Work
      Dim lw As ListingWindow = theSession.ListingWindow
      lw.Open()

      For Each myFeature As Features.Feature In workPart.Features
            If TypeOf (myFeature) Is Features.PointSet Then
                lw.WriteLine(".GetFeatureName: " & myFeature.GetFeatureName)
                lw.WriteLine(".Name: " & myFeature.Name)
                lw.WriteLine(".FeatureType: " & myFeature.FeatureType)
                lw.WriteLine(".Timestamp: " & myFeature.Timestamp.ToString)
                lw.WriteLine("")

                Dim myPoints() As NXObject = myFeature.GetEntities

                For Each tempPt As Point In myPoints
                  lw.WriteLine(tempPt.Coordinates.ToString)
                Next

            End If

      Next


      lw.Close()

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

      'Unloads the image immediately after execution within NX
      GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module

页: [1]
查看完整版本: 怎麼獲得點集內點的坐標