Imports System
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports NXOpen.UF
Module report_selected_datum_plane
Dim theSession As Session = Session.GetSession()
Dim theUFSession As UFSession = UFSession.GetUFSession()
Dim theLW As ListingWindow = theSession.ListingWindow
Sub Main()
Dim thePlane As DatumPlane
While select_a_datum_plane(thePlane ) = Selection.Response.Ok
Dim z_vec As Double() = new Double(2){thePlane.Normal.X, thePlane.Normal.Y, thePlane.Normal.Z}
Dim mtx As Double() = new Double(8){}
theUFSession.mtx3.InitializeZ(z_vec, mtx)
If Not theLW.IsOpen Then theLW.Open()
theLW.WriteLine("Datum Plane: " & thePlane.ToString())
theLW.WriteLine("Parent Feature: " & thePlane.Feature.GetFeatureName())
theLW.WriteLine("Origin: " & thePlane.Origin.ToString())
theLW.WriteLine("Normal: " & thePlane.Normal.ToString())
theLW.WriteLine("Matrix: " & vbCrLf)
theLW.WriteLine(String.Format("{0}, {1}, {2}", mtx(0), mtx(1), mtx(2)))
theLW.WriteLine(String.Format("{0}, {1}, {2}", mtx(3), mtx(4), mtx(5)))
theLW.WriteLine(String.Format("{0}, {1}, {2}", mtx(6), mtx(7), mtx(8)))
Dim origin As Double() = new Double(2){thePlane.Origin.X, thePlane.Origin.Y, thePlane.Origin.Z}
Dim x_vec As Double() = new Double(2){mtx(0), mtx(1), mtx(2)}
Dim Y_vec As Double() = new Double(2){mtx(3), mtx(4), mtx(5)}
theUFSession.Disp.Conehead(UFConstants.UF_DISP_WORK_VIEW_ONLY, origin, x_vec, 0)
theUFSession.Disp.Conehead(UFConstants.UF_DISP_WORK_VIEW_ONLY, origin, y_vec, 0)
theUFSession.Disp.Conehead(UFConstants.UF_DISP_WORK_VIEW_ONLY, origin, z_vec, 0)
End While
End Sub
Function select_a_datum_plane(ByRef selobj As DatumPlane) As Selection.Response
Dim ui As UI = ui.GetUI()
Dim message As String = "Select a datum plane"
Dim title As String = "Selection"
Dim selectionMask(0) As Selection.MaskTriple
With selectionMask(0)
.Type = UFConstants.UF_datum_plane_type
.Subtype = 0
.SolidBodySubtype = 0
End With
Dim cursor As Point3d = Nothing
Dim resp As Selection.Response = _
ui.SelectionManager.SelectObject(message, title, _
Selection.SelectionScope.WorkPart, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, selectionMask, selobj, cursor)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Then
return Selection.Response.Ok
Else
return Selection.Response.Cancel
End If
End Function
Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
End Module