I'm trying to figure out a way to delete all the balloons in a drawing. I need to Rev a bunch of drawings and need to delete all of the circular balloons we use on every sheet.
I couldn't find anything in the API help that would allow me to delete a balloon.
If anyone has any has any information on this, or a quick and dirty macro I can modify that would be great.
Thanks,
Jason
SolidworksApi macros
I have a macro that deletes a balloon based on a cross reference to a table within excel. You could modify to just delete all balloons. See below.
<p>Dim swApp As SldWorks.SldWorks<br>Dim swModel As SldWorks.ModelDoc2<br>Dim swDrw As DrawingDoc<br>Dim swView As View<br>Dim swoNote As Note<br>Dim swAnn As Annotation<br>Dim swAnns As Variant<br>Dim sSheetName() As String<br>Dim vAttEntArr As Variant<br>Dim vAttEntTypeArr As Variant<br>Dim swEnt As SldWorks.Entity<br>Dim swComp As SldWorks.Component<br>Dim i, j As Long<br>Dim CurrentConfiguration As String<br>Dim CurrentPartNumber As String<br>Dim DeleteThisBalloon As Boolean<br>Dim MyExcelApp As Object<br>Option Explicit<br>Dim ErrorBoolean As Boolean<br>Sub BalloonMain()</p><p> Call OpenExcelBalloon</p><p> Call DeleteBalloons</p><p> Call CloseExcelBalloon</p><p>End Sub</p><p><br>Sub DeleteBalloons()<br>Set swApp = Application.SldWorks<br>Set swModel = swApp.ActiveDoc</p><p>On Error GoTo balloonError</p><p>'makes sure a document of the drawing type is open<br> If swModel.GetType = swDocDRAWING Then<br> Set swDrw = swModel<br> Else<br> MsgBox "Open a drawing doc, please", vbOKOnly + vbInformation<br> Exit Sub<br> End If</p><p>'for each sheet<br> sSheetName = swDrw.GetSheetNames<br> For i = 0 To UBound(sSheetName)<br> swDrw.ActivateSheet sSheetName(i)<br> 'Debug.Print sSheetName(i)<br> Set swView = swDrw.GetFirstView<br> Do<br> swAnns = swView.GetAnnotations<br> If Not IsEmpty(swAnns) Then<br> For j = 0 To UBound(swAnns)<br> Set swAnn = swAnns(j)<br> If swAnn.GetType = swNote Then<br> Set swoNote = swAnn.GetSpecificAnnotation<br> If swoNote.IsBomBalloon Then<br> 'debug.Print " " & swoNote.GetText<br> vAttEntArr = swAnn.GetAttachedEntities2<br> vAttEntTypeArr = swAnn.GetAttachedEntityTypes<br> If swSelNOTHING <> vAttEntTypeArr(0) Then<br> Set swEnt = vAttEntArr(0)<br> Set swComp = swEnt.GetComponent<br> <br> 'MsgBox sSheetName(i)<br> CurrentConfiguration = swView.ReferencedConfiguration<br> CurrentPartNumber = swComp.Name<br> <br> 'Debug.Print CurrentConfiguration & " : " & CurrentPartNumber<br> DeleteThisBalloon = MyExcelApp.Application.Run("MainBOM.xlsm" & "!deleteballoon", CurrentConfiguration, CurrentPartNumber)<br> 'MsgBox DeleteThisBalloon<br> 'MsgBox swAnn.GetName<br> If DeleteThisBalloon Then<br> swAnn.Visible = swAnnotationHidden<br> End If<br> Debug.Print CurrentConfiguration & " : " & CurrentPartNumber & " = " & DeleteThisBalloon<br> ' Insert your code here<br> ' swComp is the component to which the balloon is attached<br> ' swAnn is the balloon annotation<br> <br> End If<br> If ErrorBoolean Then<br>balloonError:<br> Set swComp = swEnt.GetComponent<br> MsgBox "A balloon error has occured. Manually delete balloon for: " & swComp.Name<br> End If<br> ErrorBoolean = False<br> End If<br> End If<br> Next j<br> End If<br> Set swView = swView.GetNextView<br> Loop While Not (swView Is Nothing)<br> Next i</p><p></p><p><br>End Sub</p><p>Sub OpenExcelBalloon() 'opens excel, turns off screen updating and warnings<br> Set MyExcelApp = CreateObject("Excel.Application")<br> MyExcelApp.Visible = True<br> MyExcelApp.Workbooks.Open filename:="C:\Temp\MainBOM.xlsm"<br> With MyExcelApp<br> .EnableEvents = False<br>' .ScreenUpdating = False<br> .DisplayAlerts = False<br> End With<br>End Sub</p><p>Sub CloseExcelBalloon() 'closes excel turns on screen updating and warnings<br> MyExcelApp.Save<br> MyExcelApp.Quit<br>End Sub</p>