Auto balloon using iLogic

Auto balloon using iLogic

Anonymous
Not applicable
3,735 Views
8 Replies
Message 1 of 9

Auto balloon using iLogic

Anonymous
Not applicable

hey guys!

 

Trying to find a way to auto-balloon all part on drawing created using iLogic. 

 

Currently my assembly is driven by iLogic, iLogic also generates the idw but I can't find a way to balloon the part other than manually.

 

Is there a code snippet for auto balloon?

 

Thanks!

0 Likes
3,736 Views
8 Replies
Replies (8)
Message 2 of 9

HermJan.Otterman
Advisor
Advisor

Hello,

 

 

look here:  https://forums.autodesk.com/t5/inventor-customization/ilogic-coding-to-create-automated-drawing/m-p/...

 

 

to create a balloon with VBA, this is the code from the Inventor 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

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 3 of 9

Anonymous
Not applicable

Yeah I based my code for automated drawing almost entirely on this thread. But there's no mention of balloon in the thread. At least didn't see any.

 

Thanks for the code. I'll have a look at it pretty soon. You mentioned you got it from inventor help? I haven't seen anything this detailed in inventor help, where did you find it? 

0 Likes
Message 4 of 9

HermJan.Otterman
Advisor
Advisor

it comes from the help in Inventor:

 

APIhelp.png

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 5 of 9

Anonymous
Not applicable

I looked at the code from the help. It will add a balloon to the midpoint of the line that is selected. 

 

My guess is that with a For loop I could go and add a balloon to each of the part. But how would I tell it to go and look for line 1 of part1 and then line 1 of part2? 

0 Likes
Message 6 of 9

Maxim-CADman77
Advisor
Advisor

Have you achieved your goal? 

Don't you know how to automate check for ballooning all ItemRefs in PartList (manually you just check if there is a "balloon sign" in each cell of first column when in PartList editing mode)?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 7 of 9

Maxim-CADman77
Advisor
Advisor

Got it - DrawingBOMRow.Ballooned Property.

 

Sorry for have disturbed.

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 8 of 9

Anonymous
Not applicable

Herm Jan

We upgraded to Inventor Pro 2019, I have tried to run this code through the VBA EDITOR and will not run. 

Run time error '5':

Invalid procedure call or argument. 

 

The debug has gone to this line

Set oDrawingCurveSegment = oDrawDoc.SelectSet.Item(1)

 

Any suggestions

0 Likes
Message 9 of 9

HermJan.Otterman
Advisor
Advisor

this line will only work if you first have selected a line.

so select a line, (that wil than be in the "SelectSet") than run the code

if nothing is in the selectset, you will get an error.

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes