How to identify if Balloon is invisible

How to identify if Balloon is invisible

J-Camper
Advisor Advisor
540 Views
9 Replies
Message 1 of 10

How to identify if Balloon is invisible

J-Camper
Advisor
Advisor

I've run into an odd bug in an automated ballooning tool I made.  If a balloon gets attached to a body, which then becomes invisible the balloon can no longer get the attached entity. 
The exact exception reads:

System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (0x80004005 (E_FAIL))
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Object[] aArgs, Boolean[] aArgsIsByRef, Int32[] aArgsWrapperTypes, Type[] aArgsTypes, Type retType)
   at Inventor.LeaderNode.get_AttachedEntity()
   at ThisRule.Main() in rule: Rule3, in document 8275-SD05-_PANTRY-BAR.dwg:line 3
   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   at Autodesk.iLogic.Exec.AppDomExec.ExecCodeHere()
   at Autodesk.iLogic.Exec.AppDomExec.ExecCodeInOtherDomain(AppDomain otherDomain, String assemName)
   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

Test Rule:

For Each b As Balloon In ThisDrawing.ActiveSheet.Balloons.NativeEntity
	
	Logger.Trace(b.Leader.AllNodes.Item(b.Leader.AllNodes.Count).AttachedEntity Is Nothing)
	
Next


But the main line is "Inventor.LeaderNode.get_AttachedEntity()"

The balloon exists, but is not visible to the user and is throwing an error instead of returning nothing.  Does anyone know how to identify these Invisible Balloons?

Error occurs in my current Inventor build: 2025.2.1
Not sure if it is present in any other

Example Video:

0 Likes
Accepted solutions (1)
541 Views
9 Replies
Replies (9)
Message 2 of 10

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @J-Camper , I think you'd need to access the balloon from the browser nodes to see the visibility property ( if I understand correctly).
Maybe just a try/catch to handle this, would suffice?

Hope that helps, Curtis

 

For Each b As Balloon In ThisDrawing.ActiveSheet.Balloons.NativeEntity
	Try
		oEnt = b.Leader.AllNodes.Item(b.Leader.AllNodes.Count).AttachedEntity 
	Catch
		Logger.Trace("could not get AttachedEntity" )
	End Try
Next

 

EESignature

0 Likes
Message 3 of 10

J-Camper
Advisor
Advisor

@Curtis_Waguespack,

I was trying to reply, but accidentally accepted the response as an answer.  A try/catch does prevent the exception from stopping the iLogic rule and it is what i implemented to get my script back up and running, so i guess it's not bad to have accepted it.  I was looking for a method that didn't rely on Try/Catch when i made this post, but with an accepted answer there might not be as much discussion.

I don't think balloons appear in the model browser so there is no node to look at.  I just don't know why it wouldn't return the entity since it still returns that the balloon is attached when invisible. 

Message 4 of 10

Curtis_Waguespack
Consultant
Consultant

I unaccepted that reply so others will continue to have a look, hopefully someone else might come along and know of a better way.

The balloon does not have a browser node but the component does, so that was what I was think of.  But maybe that isn't the visibility setting you were working with? so I might just be adding confusion.

Curtis_Waguespack_0-1743718282281.png

 

EESignature

0 Likes
Message 5 of 10

J-Camper
Advisor
Advisor

Thank you.  Is unaccepting a thing I could have done?  I tried looking but didn't see anything right away.

Yes, if i was only after the component information I believe the BalloonValueSet would have component Information in it [following this sample].  It still doesn't let you know that the end user can see the balloon.  If the balloon gets attached to geometry that no longer exists, like an edge from a feature that gets suppressed, then the balloon will exist and return the component, but it won't be present in the drawing. 



I guess you could still use the AttachedEntity workflow in a Try/Catch, delete the balloon that fails, and add a new one, but it feels like there should be a simpler solution.

0 Likes
Message 6 of 10

a.brusamolino
Enthusiast
Enthusiast

Hi!

 

While debugging via VBA, it really seems like Inventor doesn't like the case when the component becomes invisible — the AttachedEntity field actually throws an error:

 

Debug1.png

 

I also tried the case where a feature gets suppressed, but in that scenario AttachedEntity still returns something (so the Try/Catch block won't actually catch an error there).

 

The only thing I noticed at first glance is that in both cases, the Ballooned field is set to False, so that might be a useful indicator!

 

Debug2.png

 

 

So I tried this code:

 

Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
For Each b As Balloon In oDDoc.ActiveSheet.Balloons
	Bool = b.BalloonValueSets.Item(1).ReferencedRow.Ballooned
	If Bool Then 
		MsgBox("Visible")
	Else
		MsgBox("Invisible")
	End If
Next

 

This code works in my case. BalloonValueSets only contains one element — if there are more, I’m not sure how it would behave.

 

 

Message 7 of 10

Curtis_Waguespack
Consultant
Consultant

I had another quick look at this, and was thinking that maybe the invalid annotation settings might offer some help.

 

Generally I have Highlight set to true.

 

In testing just now, I turned both setting off but I can't get the balloon to disappear when I go into a part file and suppress a fillet feature that has a balloon to that edge, so I'm not sure what's going on. But maybe these settings are something to look at?

 

Tools tab > Document Settings > Drawing tab

Curtis_Waguespack_0-1743774536910.png

 

Dim oDoc As DrawingDocument = ThisDoc.Document
oDoc.DrawingSettings.PreserveOrphanedAnnotations = False
oDoc.DrawingSettings.HighlightInvalidAnnotations = False

 

 

p.s.

You as the topic owner should be able to choose Not the Solution from the menu shown ( near the post time).

I as an Expert Elite, have the ability to mark any solution as Not the Solution as part of some low level admin privileges. 

Screenshot 2025-04-04 075147.png

EESignature

0 Likes
Message 8 of 10

J-Camper
Advisor
Advisor

That seems to work most of the time, but i think there is a bit of update lag.  I change the suppression state, open and update the assembly, then open the drawing and it returns the old value until i open the assembly again and go back to the drawing.  It is odd behavior but it is better than the try/catch in most cases, when everything has updated properly. It also doesn't work if there are more than one ballooned view in a drawing as it will return true since it is ballooned somewhere in the drawing

0 Likes
Message 9 of 10

J-Camper
Advisor
Advisor

this is are the annotation settings from my example drawings before changing them.

JCamper_0-1743798643950.png

I don't notice any difference when changing those options.

0 Likes
Message 10 of 10

J-Camper
Advisor
Advisor

I'm going to re-accept the Try/Catch note as it is what I implemented before posting, and there doesn't seem to be a better answer.

0 Likes