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

Unable to create balloon from workpoint

chrisdrogers
Contributor

Unable to create balloon from workpoint

chrisdrogers
Contributor
Contributor

I am using the Create a balloon API sample in the Inventor API sample.  I need to be able to attach the balloon to a parts work point.  I get an "unspecified error" when trying to call Sheet.Balloons.Add() with the Geometry Intent of a work point.  Is using work points for balloons restricted?

Reply
Accepted solutions (2)
1,286 Views
9 Replies
Replies (9)

AlexFielder
Advisor
Advisor

Hi @chrisdrogers,

 

Can you please share the iLogic you have so far. It's easy to miss something important when working with Dimension objects in the Inventor drawing Environment.

 

:slightly_smiling_face:

0 Likes

chrisdrogers
Contributor
Contributor

I am not using iLogic.  I am using C# with the Inventor API.  I have no issues connecting a dimension to a work point.  The only annotation that I cannot use with a work point through the Inventor API is a balloon. A very simplified version of the code is below:

 

var objectCollection = this.InventorHost.TransientObjects.CreateObjectCollection();

objectCollection.Add(ivTextOrigin);
objectCollection.Add(geometryIntentofWorkpoint);

 

this.Balloon = this.Sheet.Balloons.Add(objectCollection);

0 Likes

AlexFielder
Advisor
Advisor

Fair enough; can you share a drawing with the same geometry that is failing as in your example? (Autodesk will ask for it anyway when they see/reply to this post)

 

Also, have you seen this example:

https://github.com/ADN-DevTech/Inventor-Training-Material/blob/master/Module%2015%20-%20Drawing%20Ad...

 

public void CreateBalloon()
            {
             // Set a reference to the drawing document.
             // This assumes a drawing document is active.
              DrawingDocument oDrawDoc = (DrawingDocument)_InvApplication.ActiveDocument;

             // Set a reference to the active sheet.
             Sheet oActiveSheet  = oDrawDoc.ActiveSheet;

             // Set a reference to the drawing curve segment.
             // This assumes that a drwaing curve is selected.
             DrawingCurveSegment oDrawingCurveSegment   = oDrawDoc.SelectSet[1];

             // Set a reference to the drawing curve.
             DrawingCurve oDrawingCurve = oDrawingCurveSegment.Parent;

             // Get the mid point of the selected curve
             // assuming that the selection curve is linear
             Point2d oMidPoint  = oDrawingCurve.MidPoint;

             // Set a reference to the TransientGeometry object.
             TransientGeometry oTG  = _InvApplication.TransientGeometry;

             ObjectCollection oLeaderPoints  = _InvApplication.TransientObjects.CreateObjectCollection();

             // Create a couple of leader points.
             oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 10));
             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.
             GeometryIntent oGeometryIntent  = oActiveSheet.CreateGeometryIntent(oDrawingCurve);
             oLeaderPoints.Add(oGeometryIntent);

             // Set a reference to the parent drawing view of the selected curve
             DrawingView oDrawingView   = oDrawingCurve.Parent;

             // Set a reference to the referenced model document
             Document oModelDoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument;

             // Check if a partslist or a balloon has already been created for this model
             bool IsDrawingBOMDefined = false;
             IsDrawingBOMDefined = oDrawDoc.DrawingBOMs.IsDrawingBOMDefined(oModelDoc.FullFileName);

             Balloon oBalloon = null;


             if (IsDrawingBOMDefined) {
              // Just create the balloon with the leader points
              // All other arguments can be ignored
              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
                 AssemblyDocument oAssDoc = (AssemblyDocument)oModelDoc;
                 AssemblyComponentDefinition oComDef = oAssDoc.ComponentDefinition;
              BOM oBOM =  oComDef.BOM;


              if (oBOM.StructuredViewEnabled) {
               // 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
               PartsListLevelEnum Level = default(PartsListLevelEnum);
               if (oBOM.StructuredViewFirstLevelOnly) {
                Level = PartsListLevelEnum.kStructured;
               } else {
                Level = PartsListLevelEnum.kStructuredAllLevels;
               }

               // Create the balloon by specifying just the level
               oBalloon = oActiveSheet.Balloons.Add(oLeaderPoints,null , Level);

              } else {
               // Level and numbering options must be specified
               // The corresponding model BOM view will automatically be enabled
               NameValueMap oNumberingScheme  = _InvApplication.TransientObjects.CreateNameValueMap();

               // Add the option for a comma delimiter
               oNumberingScheme.Add("Delimiter", ",");

               // Create the balloon by specifying the level and numbering scheme
               oBalloon = oActiveSheet.Balloons.Add(oLeaderPoints,null , PartsListLevelEnum.kStructuredAllLevels, oNumberingScheme);
              }
             }
            }

(I assume this ^ is similar to the API Example? - I haven't checked it yet)

:slightly_smiling_face:

0 Likes

chrisdrogers
Contributor
Contributor

Yes, in the example you supplied and the Autodesk help, it is using a drawing curve to attain the geometry intent used.  I need to be able to use a work point to attain the geometry intent which will be used for the attachment point of the balloon.  I can use a drawing curve successfully, but when I switch to a work point I get an informative "Unspecified error".  I just need to know if it is possible to use work points for a balloon.  I do not see that specified anywhere in the API Reference or forum.

0 Likes

AlexFielder
Advisor
Advisor

In theory, once the Work Features are brought into the drawing (using the "Include WorkFeatures" function) there should be no reason why you can't use a WorkPoint to drive a location for a balloon.

What the above function does however is create a "CenterMark" object which has 5 point2d objects including its position:

 

2019-03-18 15_39_27-Reply to Message - Autodesk Community.png

 

In fact, unless I'm mistaken this is the only way of working with (and including) WorkFeature geometry in a drawing view.

 

So your solution needs to rely upon the user manually pulling the work features into the part using the built-in (manual) tools, or have the user select the relevant model.ipt browsernode and automatically run the "Include Work Features" command- something I just attempted to look up using the Event Viewer application without success!

 

Neither of which are particularly slick solutions. :disappointed_face:

 

I don't have a code example showing how to pull WorkFeatures into a drawing view (using the API) otherwise I would share it.

 

 

0 Likes

chrisdrogers
Contributor
Contributor

The drawings I am creating are fully automated and not reliant on any user interaction or selection. I am successfully using work points for linear dimensions, ordinate dimensions, leader notes, etc.  In order to use the work point, you have to create a workpoint proxy, SetIncludeStatus = true, and create a center mark at this location by using Sheet.Centermarks.AddByWorkFeature(proxy, view).  Once you have the center mark then you call Sheet.CreateGeometryIntent(centerMark, IntentTypeEnum.kPoint2dIntent).  This returns the GeometryIntent for the centermark/work point.  I use this exact logic for multiple annotations successfully, but when using this GeometryIntent for balloons it fails. 

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@chrisdrogers,

 

Unfortunately, workfeatures (like work point , workplanes) are not supported to create balloon via Inventor API. Even through UI, centermark(workpoint) can not be used to create balloons.

 

Please log this wish list at ideastation using below link.

 

https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

chrisdrogers
Contributor
Contributor
Accepted solution

Since this functionality does not exist, I have created an Inventor Idea as you requested here: https://forums.autodesk.com/t5/inventor-ideas/allow-balloons-to-work-with-work-points/idi-p/8668749

 

If anyone is inclined, please follow that link and vote on the idea to get it in versions of Inventor.

0 Likes

W_Barnett
Enthusiast
Enthusiast

Hey Chris,
Did you ever figure out a solution to this?   I'm going through the EXACT same process as you for auto-generating balloons.  I've already placed Named Workpoints, pulled them in, generated proper geometry intent coordinates....only for it to fail right when I go to generate the balloons.  I've correctly established that it has something to do with Workpoints not maintaining any sort of association with the models that they are pulled from, but besides going back to that suggested code that someone posted earlier in this thread, I wanted to know if you found any sort of work around?  I've found that that suggested code doesn't always work (hence why I changed to this method).

 

Any suggestions would be awesome.

 

Thanks!

0 Likes