Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Module delete_ID_symbols
Sub Main()
Dim theSession As Session = Session.GetSession()
If IsNothing(theSession.Parts.Work) Then
Return
End If
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Const undoMarkName As String = "Delete ID symbols: triangle up"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
If workPart.Annotations.IdSymbols.ToArray.Length = 0 Then
lw.WriteLine("No ID symbols found in current work part")
Return
End If
Dim triangleUp As New List(Of Annotations.IdSymbol)
'loop through all the ID symbols in the part
For Each tempID As Annotations.IdSymbol In workPart.Annotations.IdSymbols
Dim oldIdBuilder As Annotations.IdSymbolBuilder
oldIdBuilder = workPart.Annotations.IdSymbols.CreateIdSymbolBuilder(tempID)
'type of symbol to change
If oldIdBuilder.Type = Annotations.IdSymbolBuilder.SymbolTypes.TriangleUp Then
triangleUp.Add(tempID)
End If
oldIdBuilder.Destroy()
Next
Try
theSession.UpdateManager.ClearErrorList()
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Delete ID symbols")
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.AddToDeleteList(triangleUp.ToArray)
Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(markId2)
Catch ex As NXException
theSession.UndoToMark(markId1, undoMarkName)
MsgBox(ex.Message)
End Try
lw.Close()
End Sub
End Module