Group balloons after using the automatic balloon tool

Group balloons after using the automatic balloon tool

AlexFielder
Advisor Advisor
869 Views
3 Replies
Message 1 of 4

Group balloons after using the automatic balloon tool

AlexFielder
Advisor
Advisor

This should probably (I guess) be an Idea, but does anyone have a rule they can share that will let me select a group of separate balloons like these:

 

After Auto Balloon ToolAfter Auto Balloon ToolDesired resultDesired result

 

I haven't checked yet, but I assume this hinges on there being API access to adding the balloons.

 

Pseudo code for this would be something like:

 

Sub Main ()



SelectBalloons() ' that you want to add to the group.

SelectInsertLocation() ' for the first balloon once grouped.





End Sub

 

If you wanted to get a bit clever with it, I guess (rather than grabbing everything that the first selected part is connected to - which in this case is everything else) you could you could query items constrained to the first selected part? Or perhaps select those items that are on the same (major) axis as the first item selected.

 

Thanks in advance.

 

Alex.

 

0 Likes
870 Views
3 Replies
Replies (3)
Message 2 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@AlexFielder,

 

Hoping that below VBA code would help to group balloons.

 

Sub Main()

    Dim BalloonColl As ObjectCollection
    Set BalloonColl = ThisApplication.TransientObjects.CreateObjectCollection
    
    Set BalloonColl = SelectBalloons()
    
    MsgBox ("No of balloons selected for attachment : " & BalloonColl.Count)
    
    Dim oBalloon As Balloon
    Set oBalloon = ThisApplication.CommandManager.Pick(kDrawingBalloonFilter, "Select a balloon to be attached")
    
    If Not oBalloon Is Nothing And BalloonColl.Count > 0 Then
        Dim attachBalloon As Balloon
        For Each attachBalloon In BalloonColl
            Call oBalloon.BalloonValueSets.Add(attachBalloon.BalloonValueSets.Item(1).ReferencedRow)
            Call attachBalloon.Delete
        Next
    End If
End Sub

Function SelectBalloons() As ObjectCollection

    Dim coll As ObjectCollection
    Dim obj As Balloon
    Set coll = ThisApplication.TransientObjects.CreateObjectCollection

    Do
        Set obj = ThisApplication.CommandManager.Pick(kDrawingBalloonFilter, "Select balloons")
        
        If Not obj Is Nothing Then
            Call coll.Add(obj)
        End If
    Loop While Not obj Is Nothing
    
    Set SelectBalloons = coll

End Function

Steps to group ballons:

 

  1. Select the balloons to be attached.
  2. After selection of balloons, Press "Esc" button to exit selections.
  3. Select a balloon where all balloons needs to attach.
  4. Balloons attached are deleted and desire result will be displayed. 

A screencast is prepared and uploaded to below link.

 

http://autode.sk/2nwNyd5

 

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 3 of 4

AlexFielder
Advisor
Advisor

Thanks Chandra that's a great help.

 

I have converted the vba you supplied to an iLogic rule: 

Sub Main()
    BalloonColl = SelectBalloons()
    
    MsgBox ("No of balloons selected for attachment : " & BalloonColl.Count)
    
    Dim oBalloon As Balloon = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingBalloonFilter, "Select a balloon to attach our group to.")
    
    If Not oBalloon Is Nothing And BalloonColl.Count > 0 Then
		MessageBox.Show("Grouping Balloons")
        Dim attachBalloon As Balloon
        For Each attachBalloon In BalloonColl
            Call oBalloon.BalloonValueSets.Add(attachBalloon.BalloonValueSets(1).ReferencedRow)
            Call attachBalloon.Delete
        Next
    End If
End Sub

Public BalloonColl as ObjectCollection = Nothing

Function SelectBalloons() As ObjectCollection

    Dim coll As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	Dim obj As Balloon
    Do
        obj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingBalloonFilter, "Select balloons")
        
        If Not obj Is Nothing Then
            Call coll.Add(obj)
        End If
    Loop While Not obj Is Nothing
    
    Return coll

End Function

 

But for reasons I cannot figure out I get an (unhelpful) error message: 

 

Figured out what was going wrong, I was picking all the balloons I had placed so the rule above is trying to add a selected balloon to itself. This could be mitigated with a simple "is the current balloon the one we want to attach to?" check.

 

I will work out the details and reply shortly.

 

The other thing that would be nice, but doesn't seem to be part of the BalloonValueSets api is a sort of the balloons when the rule runs - could it be as simple as sorting the ObjectCollection after selection?

 

Thanks,


Alex.

 

0 Likes
Message 4 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@AlexFielder,

 

Currently, there is no direct sorting of ObjectCollection. Some other logic required to sort Object collection.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes