Attribute VB_Name = "DelRevTriangles1"
'--------------------------------------------------------------------09/18/2007
' DelRevTriangles.swp - Copyright 2003-2007 Leonard Kikstra
'------------------------------------------------------------------------------
Dim swApp As Object
Dim Document As Object
Dim SelectEntity As Object
' SolidWorks constants
Const swDocPART = 1
Const swDocASSEMBLY = 2
Const swDocDRAWING = 3
Const swBS_None = 0
Const swBS_Circular = 1
Const swBS_Triangle = 2
Const swBS_Hexagon = 3
Const swBS_Box = 4
Const swBS_Diamond = 5
Const swBS_SplitCirc = 6
Const swBS_Pentagon = 7
Const swBS_FlagPentagon = 8
Const swBS_FlagTriangle = 9
Const swBS_Underline = 10
Const swCThread = 1
Const swDatumTag = 2
Const swDatumTargetSym = 3
Const swDisplayDimension = 4
Const swGTol = 5
Const swNote = 6
Const swSFSymbol = 7
Const swWeldSymbol = 8
Const swCustomSymbol = 9
Const swDowelSym = 10
Const swLeader = 11
Const swBlock = 12
Const swCenterMarkSym = 13
Const swTableAnnotation = 14

'------------------------------------------------------------------------------
' Delete revision triangles from SolidWorks drawings.  As written, a revision
' triangle is identfied as any single character note with a triangle border.
'------------------------------------------------------------------------------
Sub Main()
  Set swApp = CreateObject("SldWorks.Application")         ' Attach to SWX
  Set Document = swApp.ActiveDoc                           ' Grab active doc
  If Document Is Nothing Then                              ' Is doc loaded
    MsgBox "No model loaded."                              ' Nothing - Warn
  Else                                                     ' Doc loaded"
    FileTyp = Document.GetType                             ' Get doc type
    If FileTyp = swDocDRAWING Then                         ' Is doc drawing ?
      SheetNames = Document.GetSheetNames                  ' Get sheet names
      DelCount = 0                                         ' Reset counter
      For i = 0 To Document.GetSheetCount - 1              ' For each sheet
        Document.ActivateSheet (SheetNames(i))             ' Activate sheet
        Set view = Document.GetFirstView                   ' Get first view
        While Not view Is Nothing                          ' View is valid
          Set Annotation = view.GetFirstAnnotation2        ' Get first annot
          While Not Annotation Is Nothing                  ' Annot valid?
            If Annotation.GetType = swNote Then            ' Note annotations
              Set NOTE = Annotation.GetSpecificAnnotation  ' Get specific note
              If NOTE.GetBalloonStyle = swBS_Triangle Then ' Triangle = Rev
                NoteVal = NOTE.GetText                     ' Get next note
                If Len(NoteVal) <= 2 Then                  ' 1-2 character
                  Annotation.Select2 True, 0               ' Add selection set
                  DelCount = DelCount + 1                  ' Inc del counter
                End If                                     ' # char check
              End If                                       ' Triangle border?
            End If                                         ' Note annotation
            Set Annotation = Annotation.GetNext2           ' Next annotation
          Wend                                             ' Annotation valid
          Document.DeleteSelection False                   ' Delete selection
          Set view = view.GetNextView                      ' Get next view
        Wend                                               ' View is valid
      Next i                                               ' Next sheet
      If i > 0 Then                                        ' More than 1 sheet
        Document.ActivateSheet (SheetNames(0))             ' back to 1st sheet
      End If                                               ' More than 1 sheet
      MsgBox Str(DelCount) + " revision triangles deleted" ' Display status
    End If                                                 ' Check doc type
  End If                                                   ' Check doc loaded
End Sub

