AnsweredAssumed Answered

Select all Inspection Balloons - Open Property manager

Question asked by Ed Horne on Jul 28, 2017

Hello,

I was asked to create a macro that would select all the Inspection balloons on a drawing. The reason for the selection is to be able to edit fonts, etc. I didn't find a lot of previous threads for something like this so I'll share what I have (feel free to offer suggestions for improvement also).

I'm able to get all the balloons selected but it would be nice if the Property Manager panel was open after running the macro. As it works now, you have to click one of the balloons post macro to get the panel to open.

Thanks in advance.

 

' ******************************************************************************
' SelectBalloons - written 07/27/17
' Macro will select all Notes on layer "Balloon"
'
' Some of the code comes from the "API: Delete All Notes on a Specified Layer"
'   written by Cheryl O'Neill
' ******************************************************************************
'
Option Explicit

Dim swApp           As SldWorks.SldWorks
Dim swModel         As SldWorks.ModelDoc2

Sub main()
    Dim swView      As SldWorks.View
    Dim swDraw      As SldWorks.DrawingDoc
    Dim swAnn       As SldWorks.Annotation
    Dim bRet        As Boolean

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel
    Set swView = swDraw.GetFirstView

    swModel.ClearSelection2 True
    While Not swView Is Nothing
        Set swAnn = swView.GetFirstAnnotation2
        While Not swAnn Is Nothing

            If swNote = swAnn.GetType Then
                If swAnn.Layer = "Balloons" Then
                    bRet = swAnn.Select2(True, 0)
                End If
            End If
                               
            Set swAnn = swAnn.GetNext2
        Wend
           
        Set swView = swView.GetNextView
    Wend
MsgBox (swModel.SelectionManager.GetSelectedObjectCount)
End Sub

Outcomes