Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module pointsInfo_fbs1
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim response2 As Selection.Response = Nothing
Dim pnt2() As Double = {0.0, 0.0, 0.0}
Dim selectedObjects As NXObject() = Nothing
theSession.ListingWindow.Open()
Start1:
response2 = selectPoints(selectedObjects)
If response2 = Selection.Response.Cancel Then GoTo End1
Dim info As String = "Number of selected objects = "
info = String.Concat(info, selectedObjects.Length)
theSession.ListingWindow.WriteLine(info)
For Each sda As Point In selectedObjects
theSession.ListingWindow.WriteLine("X= " & sda.Coordinates.X.ToString("N4") & _
" Y= " & sda.Coordinates.Y.ToString("N4") & _
" Z= " & sda.Coordinates.Z.ToString("N4"))
Next
'For Each sda As Point In selectedObjects
' ufs.Curve.AskPointData(sda.Tag, pnt2)
' theSession.ListingWindow.WriteLine("X= " & pnt2(0).ToString("N4") & " Y= " & pnt2(1).ToString("N4") & " Z= " & pnt2(2).ToString("N4"))
'Next
GoTo Start1 ' Continue selecting points
End1:
End Sub
Function selectPoints(ByRef selectedObjects As NXObject()) As Selection.Response
Dim ui As UI = ui.GetUI()
Dim mask(0) As Selection.MaskTriple
With mask(0)
.Type = UFConstants.UF_point_type
.Subtype = UFConstants.UF_point_subtype
.SolidBodySubtype = 0
End With
Try
Dim resp As Selection.Response = _
ui.SelectionManager.SelectObjects("Select Points", "Select Points", _
Selection.SelectionScope.AnyInAssembly, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, mask, selectedObjects)
If resp = Selection.Response.Cancel Or _
resp = Selection.Response.Back Then
Return Selection.Response.Cancel
Else
Dim info As String = "Number of selected objects = "
info = String.Concat(info, selectedObjects.Length)
System.Diagnostics.Trace.WriteLine(info)
Return Selection.Response.Ok
End If
Catch e As Exception
System.Diagnostics.Trace.WriteLine("Problems selecting objects.")
System.Diagnostics.Trace.WriteLine(e.ToString)
End Try
End Function
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