Auto Balloon API

Auto Balloon API

Melinda1
Participant Participant
703 Views
6 Replies
Message 1 of 7

Auto Balloon API

Melinda1
Participant
Participant

I am using iLogic to create some .idw drawings in Inventor. On the first sheet, the drawings have a single view with a Parts List. My question is: how do I use iLogic to "auto balloon" my view? It's pretty simple to "auto balloon" using the ribbon dialog control, but the idea is to batch create drawings without requiring any user interaction. I would think there would be an iLogic API for this, but I can't seem to find it. I've searched the forums, but can only find examples of code looping through the parts and adding each balloon one at a time.  This seems overly complex, especially since the "auto balloon" functionality works so well from the dialog.  I would have to think there is some sort of underlying API, which is accepting the parameters from the dialog and controlling the underlying functionality.  I just can't seem to find it though.  Can somebody point me in the right direction? Thanks!

0 Likes
704 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

I found this command, but haven't tried it yet:  "DrawingAutoBalloonSelectAll".

I know you were looking for API, but this was what I came across the last time I looked into it.

 

Edit:  I think I copied the wrong one...I had a list of common commands, and had the 'next' one selected by mistake.  Anyways, here is the other command "DrawingBalloonAllCmd".  I can't remember, but the other one may be used in the process.  There are a bunch of commands related to Balloons in drawings.  Unfortunately, executing commands does not usually work well with 'batch' type automation routines where they may be used within a loop.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 7

A.Acheson
Mentor
Mentor

Hi @Melinda1 

Placing annotations is probably one of the most complex task to do in drawings. Which is why you will find limited resources. The autoballoon command has a lot happening in the back ground. Here is the API sample to place one balloon written in VBA. If you can attach a code you have worked on then maybe users can point you in the right direction. Just don't assume it will be a five minute task. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 4 of 7

Frederick_Law
Mentor
Mentor

@A.Acheson wrote:

Placing annotations is probably one of the most complex task to do in drawings.


Yeap, everyone ignored all those manual click to place annotations.

You got a balloon, where do you want it?

Over there.  Where?

Left of the view.  How far left?

Far enough not to block model edge.  How far is far enough? 0.5"? 1"? 2"?

0 Likes
Message 5 of 7

Melinda1
Participant
Participant
Thanks WCrihfield, but that command will display the Auto Balloon dialog to the user, which is not what I want. I need something that will auto balloon a view without any user interaction.
0 Likes
Message 6 of 7

Melinda1
Participant
Participant
Hi A.Acheson,

Wow! That is a lot of code for a single balloon. That is what I was afraid of.

I have a simple function for creating a drawing, which is passed a Document object and the full name of a template file:

Function CreateDrawing(oDoc As Document, templateFile As String) As DrawingDocument
'Create drawing
Dim oDrawingDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject,templateFile,True)
oDrawingDoc.Activate()

'Add view
Dim oSheet As Sheet = oDrawingDoc.Sheets.Item(1)
Dim oCentralPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width/2.5, oSheet.Height/2)
Dim oView As DrawingView
oView = oSheet.DrawingViews.AddBaseView(oDoc,oCentralPoint, 1/10, ViewOrientationTypeEnum.kCurrentViewOrientation, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle)


' Create the parts list.
Dim oBorder As Border
oBorder = oSheet.Border
Dim oPlacementPoint As Point2d
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oBorder.RangeBox.MaxPoint.X, oBorder.RangeBox.MaxPoint.Y)
Dim oPartsList1 As PartsList
oPartsList1 = oSheet.PartsLists.Add(oView, oPlacementPoint, PartsListLevelEnum.kPartsOnly)

'Balloon View?
'Add balloons to object oView which match oPartsList1

CreateDrawing = oDrawingDoc
End Function

It works exactly as I need it to, except I can't figure out a simple way to balloon the view. Based on the Auto Balloon dialog, it seems like there should be some simple API behind the dialog with a few parameters getting passed (a View for the Selection, a Point for the Placement, some enums for the balloon shape and around/horizontal/vertical, and maybe an Offset Spacing parameter). If there isn't any existing API like this, is there a way to request it from the developers?
0 Likes
Message 7 of 7

A.Acheson
Mentor
Mentor

That sample does appear long but alot of it is just preparing the conditions to place a balloon. But you need a curve first then what type of curve( example a part with a flat spot on top is probably a good place to attach the leader so selected this curve then you need the point to attach the leader which is the midpoint and then this becomes the intent.

 

Then you want the position of where to place the balloon center.

 

Of course if you don't want to ma ually select you need to loop through each occurrence and all the curves and find a nice curve to put the balloon. How you define nice is a users decision. I find the best one in my situation is the top most curve on the elevation view. 

 

From the sample the business pieces. Not a working code.

 

    Dim oLeaderPoints As ObjectCollection
    oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection

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

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

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

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

    ' 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
    oGeometryIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve)
    Call oLeaderPoints.Add(oGeometryIntent)
    ' Create the balloon by specifying the level and numbering scheme
    oBalloon = oActiveSheet.Balloons.Add(oLeaderPoints, , kStructuredAllLevels, oNumberingScheme

 

 

To automate the Command balloon I don't think there is a way to automate this as that command doesn't have any API. To do this will involve mouse moves, control the dialogue box using key strokes. I did attempted it at one stage but made no headway. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan