Find Detached Balloons Not Working

Find Detached Balloons Not Working

gustavo.cassel
Advocate Advocate
422 Views
3 Replies
Message 1 of 4

Find Detached Balloons Not Working

gustavo.cassel
Advocate
Advocate

Hello,

I'm trying to find if some drawing documents have detached balloons.

But it seems that the .Attached property is not returning the correct value.

Here is the code that I have:

    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    
    Debug.Print oDrawDoc.ActiveSheet.Balloons.Count
    
    Dim LocalBalloon As Balloon
    For Each LocalBalloon In oDrawDoc.ActiveSheet.Balloons
        Debug.Print LocalBalloon.Attached
    Next LocalBalloon

 

And an image with a detached balloon, the property returns true.

 error.PNG

0 Likes
Accepted solutions (2)
423 Views
3 Replies
Replies (3)
Message 2 of 4

jjstr8
Collaborator
Collaborator
Accepted solution

The .Attached property's value is based on whether or not it is tied to a component, so the value you're seeing is correct.  It would be rare to have a detached one, since Inventor deletes balloons for components that are no longer in the referenced model.  If you want to know if the leader is attached to an edge (as opposed to loose positioned) check balloon.Leader.AllLeafNodes(1).AttachedEntity to see if there's a GeometryIntent it references.

0 Likes
Message 3 of 4

JelteDeJong
Mentor
Mentor
Accepted solution

I see that you are using VBA. I would advise you to start learning iLogic. You might want to read this post "Is VBA in Inventor obsolete?".

Your rule would then look something like this:

Dim oDrawDoc As DrawingDocument = ThisDoc.Document

For Each LocalBalloon As Balloon In oDrawDoc.ActiveSheet.Balloons
    Dim nodes = LocalBalloon.Leader.AllNodes
    Dim lastNode = nodes.Item(nodes.Count)

    If (lastNode.AttachedEntity Is Nothing) Then
        logger.Info("Unattached node found")
    End If
Next

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 4 of 4

gustavo.cassel
Advocate
Advocate

Hi @JelteDeJong, thanks for the reply, it worked well.

And for the VBA code, I only use for this small tests.

For me the VBA code editor makes easy to debug any function to study the API.

The detached balloon finder will be included in my add-in in C#.

 

Again, thanks for the reply! Helped a lot.

Regards,

0 Likes