Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Hi Michael,

 

Please find the following VBA code to draw the text across 3'0 clock and 9'o clock. Similarly, the code can be extended for 9'o clock and 12'o clock.

 

On running this code, it will ask to select a balloon. After selection, 2 texts are generated and positioned at 3'o clock and 9'o clock.

 

Sub Main()

    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    Dim oBalloon As Balloon
    Set oBalloon = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingBalloonFilter, "Select a balloon")

    Dim oStyle As BalloonStyle
    For Each oStyle In oDrawDoc.StylesManager.BalloonStyles
    
    If oStyle.Name = "Balloon Qty" Then
        Set oStyle = oDrawDoc.StylesManager.BalloonStyles.Item("Balloon Qty")
    End If
    
    Next
    
    If oStyle Is Nothing Then
        Set oStyle = oDrawDoc.StylesManager.BalloonStyles.Item(1).Copy("Balloon Qty")
    End If

    oStyle.BalloonType = BalloonTypeEnum.kCircularWithOneEntryBalloonType

    oStyle.Properties = "PartsListProperty='45575'"

    oBalloon.Style = oStyle

    Dim strQty As String
    strQty = oBalloon.BalloonValueSets.Item(1).Value
    strQty = strQty & "X"

    oBalloon.Style = oDrawDoc.StylesManager.BalloonStyles.Item(1)

    oBalloon.SetBalloonType (BalloonTypeEnum.kCircularWithOneEntryBalloonType)

    Call oStyle.Delete

    Dim txtPt3o As Point2d
    Set txtPt3o = ThisApplication.TransientGeometry.CreatePoint2d(oBalloon.Position.X, oBalloon.Position.Y)
    txtPt3o.X = txtPt3o.X + oBalloon.Style.BalloonDiameter / 2
    txtPt3o.Y = txtPt3o.Y + oDrawDoc.StylesManager.TextStyles.Item(1).FontSize / 2

    Dim oText3o As Inventor.GeneralNote
    Set oText3o = oDrawDoc.Sheets.Item(1).DrawingNotes.GeneralNotes.AddFitted(txtPt3o, strQty)

    Dim txtPt9o As Point2d
    Set txtPt9o = ThisApplication.TransientGeometry.CreatePoint2d(oBalloon.Position.X, oBalloon.Position.Y)
    txtPt9o.X = (txtPt9o.X - (oBalloon.Style.BalloonDiameter / 2)) - (oDrawDoc.StylesManager.TextStyles.Item(1).WidthScale * 0.6)
    txtPt9o.Y = txtPt9o.Y + oDrawDoc.StylesManager.TextStyles.Item(1).FontSize / 2

    Dim oText9o As Inventor.GeneralNote
    Set oText9o = oDrawDoc.Sheets.Item(1).DrawingNotes.GeneralNotes.AddFitted(txtPt9o, strQty)

End Sub

Please feel free to contact if there is any doubt.

 

If solves your problem, click on "Accept as solution" / give a "Kudo"

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network