Option Strict Off
Imports System
Imports System.Environment
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.Annotations
Imports NXOpen.Utilities
Module NXSelection
Dim s As Session = Session.GetSession()
Dim ui As UI = ui.GetUI()
Dim ufs As UFSession = UFSession.GetUFSession()
Sub Main()
Dim edge1 As NXObject = Nothing
Dim obj As NXObject = Nothing
Dim cursor As Point3d = Nothing
Dim response1 As Selection.Response = Selection.Response.Cancel
response1 = selectDraftingEdgeorCurve("Select a Curve", edge1, cursor)
If response1 = Selection.Response.Cancel Then GoTo trynote1
trynote1:
response1 = SelectNoteorLabel(obj, cursor)
If response1 = Selection.Response.Cancel Then GoTo end1
end1:
End Sub
Function selectDraftingEdgeorCurve(ByVal prompt As String, ByRef obj As NXObject, _
ByRef cursor As Point3d) As Selection.Response
ufs.Ui.SetCursorView(0)
Dim mask(8) As Selection.MaskTriple
mask(0).Type = UFConstants.UF_solid_type
mask(0).Subtype = UFConstants.UF_solid_body_subtype
mask(0).SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE
mask(1).Type = UFConstants.UF_line_type
mask(1).Subtype = 0
mask(1).SolidBodySubtype = 0
mask(2).Type = UFConstants.UF_circle_type
mask(2).Subtype = 0
mask(2).SolidBodySubtype = 0
mask(3).Type = UFConstants.UF_conic_type
mask(3).Subtype = 0
mask(3).SolidBodySubtype = 0
mask(4).Type = UFConstants.UF_spline_type
mask(4).Subtype = 0
mask(4).SolidBodySubtype = 0
mask(5).Type = UFConstants.UF_solid_silhouette_type
mask(5).Subtype = 0
mask(5).SolidBodySubtype = 0
mask(6).Type = UFConstants.UF_section_edge_type
mask(6).Subtype = 0
mask(6).SolidBodySubtype = 0
mask(7).Type = UFConstants.UF_section_line_type
mask(7).Subtype = 0
mask(7).SolidBodySubtype = 0
mask(8).Type = UFConstants.UF_section_segment_type
mask(8).Subtype = 0
mask(8).SolidBodySubtype = 0
Dim resp As Selection.Response = _
ui.SelectionManager.SelectObject(prompt, prompt, _
Selection.SelectionScope.AnyInAssembly, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, mask, obj, 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 SelectNoteorLabel(ByRef obj As NXObject, _
ByRef cursor As Point3d) As Selection.Response
Dim mask(1) As Selection.MaskTriple
mask(0).Type = NXOpen.UF.UFConstants.UF_drafting_entity_type
mask(0).Subtype = NXOpen.UF.UFConstants.UF_draft_note_subtype
mask(1).Type = NXOpen.UF.UFConstants.UF_drafting_entity_type
mask(1).Subtype = NXOpen.UF.UFConstants.UF_draft_label_subtype
Dim resp As Selection.Response = ui.SelectionManager.SelectObject("Select Note or Label", _
"Select Note or Label", Selection.SelectionScope.WorkPart, _
Selection.SelectionAction.ClearAndEnableSpecific, False, _
False, mask, obj, 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
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module