AnsweredAssumed Answered

"Add Auto Balloons to Drawing Example (VBA)" example does not work

Question asked by Mike Campbell on Jan 22, 2015
Latest reply on Jan 22, 2015 by Mike Campbell

This is the code found in the API help and it does work fine but please read on...

'------------------------------------------------------------------------------
' Preconditions: Open a drawing with a bill of materials (BOM) table.
'
' Postconditions: The specified BOM balloons are added to the view.
'------------------------------------------------------------------------------
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim vNotes As Variant
Dim autoballoonParams As SldWorks.AutoBalloonOptions
Dim boolstatus As Boolean

Option Explicit

Sub main()

    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc
    boolstatus = Part.ActivateView("Drawing View1")
    boolstatus = Part.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)

    Set autoballoonParams = Part.CreateAutoBalloonOptions()
    autoballoonParams.Layout = swDetailingBalloonLayout_Square
    autoballoonParams.ReverseDirection = False
    autoballoonParams.IgnoreMultiple = True
    autoballoonParams.InsertMagneticLine = True
    autoballoonParams.LeaderAttachmentToFaces = True
    autoballoonParams.Style = swBS_Circular
    autoballoonParams.Size = swBF_5Chars
    autoballoonParams.UpperTextContent = swBalloonTextItemNumber
    autoballoonParams.UpperText = ""
    autoballoonParams.Layername = "-None-"
    autoballoonParams.ItemNumberStart = 1
    autoballoonParams.ItemNumberIncrement = 1
    autoballoonParams.ItemOrder = swBalloonItemNumbers_DoNotChangeItemNumbers
    autoballoonParams.EditBalloons = True
    autoballoonParams.EditBalloonOption = swEditBalloonOption_Resequence

    vNotes = Part.AutoBalloon5(autoballoonParams)
   

End Sub

'---------------------------------------------------------------------------------------------------

 

The following subtle variation on the example, above, yields nothing at all, not even an error.

'------------------------------------------------------------------------------------------------------
Dim Part As SldWorks.ModelDoc2
Dim vNotes As Variant
Dim autoballoonParams As SldWorks.AutoBalloonOptions
Dim boolstatus As Boolean

Option Explicit

Sub main()

    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc
    boolstatus = Part.ActivateView("Drawing View1")
    boolstatus = Part.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)

    Set autoballoonParams = Part.CreateAutoBalloonOptions()
    autoballoonParams.Layout = swDetailingBalloonLayout_Square
    autoballoonParams.ReverseDirection = False
    autoballoonParams.IgnoreMultiple = True
    autoballoonParams.InsertMagneticLine = True
    autoballoonParams.LeaderAttachmentToFaces = True
    autoballoonParams.Style = swBS_Circular
    autoballoonParams.Size = swBF_5Chars
    autoballoonParams.UpperTextContent = swBalloonTextComponentReference ' Here's the only difference
    autoballoonParams.UpperText = ""
    autoballoonParams.Layername = "-None-"
    autoballoonParams.ItemNumberStart = 1
    autoballoonParams.ItemNumberIncrement = 1
    autoballoonParams.ItemOrder = swBalloonItemNumbers_DoNotChangeItemNumbers
    autoballoonParams.EditBalloons = True
    autoballoonParams.EditBalloonOption = swEditBalloonOption_Resequence

    vNotes = Part.AutoBalloon5(autoballoonParams)
   

End Sub

Outcomes