cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Correct API Documentation on Creation a balloon

Correct API Documentation on Creation a balloon

TiffanyHaydenSWQYG_0-1651243223884.png

 

 

This example subroutine is in the API Help within Inventor. But it does not attach to the midpoint. You have to add the midpoint to the geometry intent creation. This documentation has been incorrect since at least 2016 and would be helpful if it was corrected for future developers. 

 

This line: 

Set oGeometryIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve)

Needs to change to: 

 

Set oGeometryIntent = oSheet.CreateGeometryIntent(oDrawingCurve, oMidPoint)

 

 

Code Example from API Help: 

 

Public Sub CreateBalloon()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    ' Set a reference to the active sheet.
    Dim oActiveSheet As Sheet
    Set oActiveSheet = oDrawDoc.ActiveSheet

    ' Set a reference to the drawing curve segment.
    ' This assumes that a drwaing curve is selected.
    Dim oDrawingCurveSegment As DrawingCurveSegment
    Set oDrawingCurveSegment = oDrawDoc.SelectSet.Item(1)

    ' Set a reference to the drawing curve.
    Dim oDrawingCurve As DrawingCurve
    Set oDrawingCurve = oDrawingCurveSegment.Parent

    ' Get the mid point of the selected curve
    ' assuming that the selection curve is linear
    Dim oMidPoint As Point2d
    Set oMidPoint = oDrawingCurve.MidPoint

    ' Set a reference to the TransientGeometry object.
    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry

    Dim oLeaderPoints As ObjectCollection
    Set oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection

    ' Create a couple of leader points.
    Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 10))
    Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 5))

    ' Add the GeometryIntent to the leader points collection.
    ' This is the geometry that the balloon will attach to.
    Dim oGeometryIntent As GeometryIntent
    Set oGeometryIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve)
    Call oLeaderPoints.Add(oGeometryIntent)

    ' Set a reference to the parent drawing view of the selected curve
    Dim oDrawingView As DrawingView
    Set oDrawingView = oDrawingCurve.Parent

    ' Set a reference to the referenced model document
    Dim oModelDoc As Document
    Set oModelDoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument

    ' Check if a partslist or a balloon has already been created for this model
    Dim IsDrawingBOMDefined As Boolean
    IsDrawingBOMDefined = oDrawDoc.DrawingBOMs.IsDrawingBOMDefined(oModelDoc.FullFileName)

    Dim oBalloon As Balloon

    If IsDrawingBOMDefined Then

        ' Just create the balloon with the leader points
        ' All other arguments can be ignored
        Set oBalloon = oDrawDoc.ActiveSheet.Balloons.Add(oLeaderPoints)
    Else

        ' First check if the 'structured' BOM view has been enabled in the model

        ' Set a reference to the model's BOM object
        Dim oBOM As BOM
        Set oBOM = oModelDoc.ComponentDefinition.BOM

        If oBOM.StructuredViewEnabled Then

            ' Level needs to be specified
            ' Numbering options have already been defined
            ' Get the Level ('All levels' or 'First level only')
            ' from the model BOM view - must use the same here
            Dim Level As PartsListLevelEnum
            If oBOM.StructuredViewFirstLevelOnly Then
                Level = kStructured
            Else
                Level = kStructuredAllLevels
            End If

            ' Create the balloon by specifying just the level
            Set oBalloon = oActiveSheet.Balloons.Add(oLeaderPoints, , Level)
        Else

            ' Level and numbering options must be specified
            ' The corresponding model BOM view will automatically be enabled
            Dim oNumberingScheme As NameValueMap
            Set oNumberingScheme = ThisApplication.TransientObjects.CreateNameValueMap

            ' Add the option for a comma delimiter
            oNumberingScheme.Add "Delimiter", ","

            ' Create the balloon by specifying the level and numbering scheme
            Set oBalloon = oActiveSheet.Balloons.Add(oLeaderPoints, , kStructuredAllLevels, oNumberingScheme)
        End If
    End If
End Sub

 

 

 

 

 

 

 Example forum post shows it's been wrong since 2016.

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/creation-balloon-why-not-picking-mid...

 

8 Comments
YuhanZhang
Autodesk

Hi @Tiffany_Hayden_ ,

 

In the VBA sample we did not explicitly indicate the balloon will be attached to the mid point of a linear drawing curve, the mid point is used to calculate the position of the balloon and leader line. Of course if you want to attach the balloon to the mid point of the linear drawing curve your suggestion CreateGeometryIntent(oDrawingCurve, oMidPoint) will work. 

 

I will update the comment/description to make the sample more clear to understand, and thanks for your suggestions.

Tiffany_Hayden_
Collaborator

@YuhanZhang 

I definitely do understand that. As a developer looking at that example and trying to figure out why it's only attaching to the endpoint every time or what to change to make it attach to something else is hard to figure out, primarily if you have never worked with balloons. The thinking you not only have to define the position of the balloon but also add the point to the geometry to make it attach where you want was not in very much documentation.

 

That being said I really appreciate your consideration! Thanks so much! 

Yijiang.Cai
Autodesk
Status changed to: Future Consideration

Many thanks for posting the idea, and tracked as [INVGEN-75809]

dan_szymanski
Autodesk
Status changed to: Implemented

This idea has been implemented within Autodesk Inventor 2025.2. Please review the following article here, for more information regarding how you may leverage this API. Special thanks to everyone who cast a vote for it.

Tiffany_Hayden_
Collaborator

Thanks so much @dan_szymanski and team! I'm so glad this documentation for balloons has been updated. It will help everyone interested in ballooning automation. Appreciate it! 

Lokesh-BAE
Contributor

Hi, 

I am looking for creation of balloons for multiple "selected linear curves" of a drawing. Basically I would like to place multiple balloons a time for the selected components edges at particular "X" & "Y" positions. I tried using for loop in the above code. Somehow after placement of first balloon, program halts with the error. As I understand, once first balloon is created, the selection of curves is no more valid or it disappears and the code not able to jump to the next selected linear curve. 

Is there any work around solutions?

Of course  "Auto Balloon" option is not a good suit for me as it places the balloons in a clumsy way. Basically I would like to control the placement of balloons in "Auto Balloon" option.

 

Thanks for the reply in advance.

Tiffany_Hayden_
Collaborator

@Lokesh-BAE You may be ballooning a line that is not visible. I know errors will occur that way. You may try a try/catch or a " On error resume next" if in vba. 

Lokesh-BAE
Contributor

@Tiffany_Hayden_  Hi, I would like to place balloons for multiple items at a time (in a single run cycle of the macro code) at specified X & Y coordinates from the mid point of these selected (visible) lines. Can you please suggest..

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea