Code:
Option Strict OffImports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities
Module find_all_notes_on_current_drawing_sheet
Public s As Session = Session.GetSession()
Public ufs As UFSession = UFSession.GetUFSession()
Public lw As ListingWindow = s.ListingWindow
Sub Main()
Dim dp As Integer = 0
dp = check_for_missing_display_part()
If dp = 1 Then
Return
End If
Dim curDwg As NXOpen.Tag = NXOpen.Tag.Null
ufs.Draw.AskCurrentDrawing(curDwg)
Dim dwgObj As Drawings.DrawingSheet = NXObjectManager.Get(curDwg)
If curDwg = NXOpen.Tag.Null Then
MsgBox("No Current Drawing", MsgBoxStyle.Exclamation)
Return
End If
Dim dwgView As NXOpen.Tag = NXOpen.Tag.Null
ufs.Draw.AskViewOfDrawing(curDwg, dwgView)
' find the notes on the Drawing view
Dim obj As NXOpen.Tag = NXOpen.Tag.Null
Dim type As Integer = 0
Dim subtype As Integer = 0
MsgBox("Processing Drawing Sheet objects", MsgBoxStyle.Information)
Do
ufs.View.CycleObjects(dwgView,
UFView.CycleObjectsEnum.VisibleObjects, obj)
If obj <> NXOpen.Tag.Null Then
ufs.Obj.AskTypeAndSubtype(obj, type, subtype)
If type = UFConstants.UF_drafting_entity_type And _
subtype = UFConstants.UF_draft_note_subtype Then
ufs.Disp.SetHighlight(obj, 1)
MsgBox("Note Found", MsgBoxStyle.Information)
ufs.Disp.SetHighlight(obj, 0)
End If
End If
Loop Until obj = NXOpen.Tag.Null
'Cycle the Drawing Member views, finding each note on each View
Dim memViews() As Drawings.DraftingView = dwgObj.GetDraftingViews()
For counter As Integer = 0 To memViews.GetUpperBound(0)
MsgBox("Processing member view: " & memViews(counter).Name())
obj = NXOpen.Tag.Null
Do
ufs.View.CycleObjects(memViews(counter).Tag, _
UFView.CycleObjectsEnum.VisibleObjects, obj)
If obj <> NXOpen.Tag.Null Then
ufs.Obj.AskTypeAndSubtype(obj, type, subtype)
If type = UFConstants.UF_drafting_entity_type And _
subtype = UFConstants.UF_draft_note_subtype Then
ufs.Disp.SetHighlight(obj, 1)
MsgBox("Note Found", MsgBoxStyle.Information)
ufs.Disp.SetHighlight(obj, 0)
End If
End If
Loop Until obj = NXOpen.Tag.Null
Next
End Sub
Public Function check_for_missing_display_part() As Integer
Dim dispPart As Part = Nothing
Try
dispPart = s.Parts.Display
Catch ex As Exception
lw.Open()
lw.WriteLine("+++Error: " & ex.ToString())
End Try
If dispPart Is Nothing Then
lw.Open()
lw.WriteLine("There is no current Displayed Part")
ufs.UF.PrintSyslog("+++ERROR: There is no current Displayed Part", _
False)
Return 1
End If
Return 0
End Function
Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
End Module