
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module PointsInformation

    '  Explicit Activation
    '      This entry point is used to activate the application explicitly
    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

	theSession.ListingWindow.Open


Start1:
Start2:
        response2 = select_a_Point(selectedObjects)
        If response2 = Selection.Response.Back Then GoTo Start1 ' Select a new face
        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)


        Dim sda As Point
        For Each sda In selectedObjects
	        ufs.Curve.AskPointData(sda.Tag, pnt2)
		theSession.ListingWindow.WriteLine("X," & pnt2(0).ToString("N14") & " Y," & pnt2(1).ToString("N14") & " Z,"& pnt2(2).ToString("N14"))
	Next

        GoTo Start2 ' Continue selecting points for current face

End1:
    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

        '----Other unload options-------
        'Unloads the image when the NX session terminates
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
        '-------------------------------

    End Function

    Function select_a_Point(ByRef selectedObjects As NXObject())
        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

End Module

