5 Replies Latest reply on Oct 23, 2018 2:36 PM by Scott Stuart

    trying to get a macro button to remove two approval notes off my prints

    Mike Flanders

      Hey guys, for the life of me I cannot get a macro to record the removal of the same two notes from my prints. I use a macro to grab them from my design library and place them where I want but I want to do the same thing only remove them.

       

      I have a series of macros that I click to add "approval notes", "dual dimension sheet", "save an approval copy as PDF" in a certain folder, "undo dual dimensions on sheet",   "-----------------------"save as PDF on our network location" then a "single button print"

       

      the "---------------------" is the button I want to click to remove the notes that I applied at the start of this sequence.

       

       

      Eventually I'd like to combine all these to be a one click to do this whole sequence but i'll look into that later.

      macro sequence.JPG

        • Re: trying to get a macro button to remove two approval notes off my prints
          Scott Stuart

          Here's a macro I have to delete revision triangles from a drawing. This works by looking for note annotation that have a triangle border, but you should be able to modify it to look for notes with a specific wording.

           

          Option Explicit
          Dim swApp As Object
          Dim iCnt, iTotal, num As Integer
          Dim retVal As Variant
          Dim vSheetNames As Variant
          Dim swView As SldWorks.View
          Dim swModel As SldWorks.ModelDoc2
          Dim swModExt As SldWorks.ModelDocExtension
          Dim swSelMgr As SldWorks.SelectionMgr
          Dim swSelData As SldWorks.SelectData
          Dim swDrawing As SldWorks.DrawingDoc
          Dim swNote As SldWorks.Note
          Dim swAnn As SldWorks.Annotation
          Dim userconf As Boolean
          Sub Main()
          
          
          Set swApp = Application.SldWorks
          Set swModel = swApp.ActiveDoc
          If swModel Is Nothing Then Exit Sub
          
          
          If swModel.GetType <> swDocDRAWING Then
              MsgBox "This only works on drawings."
              Exit Sub
          End If
          
          
          Set swModExt = swModel.Extension
          Set swSelMgr = swModel.SelectionManager
          Set swSelData = swSelMgr.CreateSelectData
          swModel.ClearSelection2 True
          
          
          Set swDrawing = swModel
          
          
          vSheetNames = swDrawing.GetSheetNames
          iTotal = UBound(vSheetNames) + 1
          iCnt = 0
          userconf = False
          
          
          Do While iCnt < iTotal
              retVal = swDrawing.ActivateSheet(vSheetNames(iCnt))
              Set swView = swDrawing.GetFirstView ' first one is the sheet, next is the first view
              Do While Not swView Is Nothing
                  Set swNote = swView.GetFirstNote
                  Do While Not swNote Is Nothing
                      Set swAnn = swNote.GetAnnotation
                      If swNote.GetBalloonStyle = swBS_Triangle Then
                          retVal = swAnn.Select3(True, swSelData)
                          If Not userconf Then
                              If MsgBox("Are you sure you want to delete all rev triangles?", vbYesNo + vbSystemModal) = vbYes Then
                                  userconf = True
                              Else
                                  Exit Sub
                              End If
                          End If
                      End If
                      Set swNote = swNote.GetNext
                  Loop
                  If swSelMgr.GetSelectedObjectCount2(0) Then Debug.Print "Deleted? " & swModExt.DeleteSelection2(0)
                  Set swView = swView.GetNextView
              Loop
              iCnt = iCnt + 1
          Loop
          
          
          swDrawing.ActivateSheet vSheetNames(0)
          
          
          End Sub
          
          • Re: trying to get a macro button to remove two approval notes off my prints
            Artem Taturevych

            I would recommend to tag the notes (Add Tag To Selected Note). So you will be always able to find the required note (even if the text is changed). Here is an example which changes the numeric value of the tagged note, but you can modify it to delete note instead: Increment The Numeric Value In The Note