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

Creation of Balloon set using Ilogic

nvmierlo
Contributor

Creation of Balloon set using Ilogic

nvmierlo
Contributor
Contributor

Dear All, 

I have successfully (with much help from this forum) created a Ilogic code that puts 3 balloons on my drawing (first picture)  however, I want to attach all three balloons to one leader (second picture). I am using named geometry to define the start points of the balloons leaders.

 

I have found the following code string in the Inventor API help: BalloonValueSets.Add( Component As Object ) As BalloonValueSet . But I cannot get it to work in my code. Any help is appreciated, thank you in advance! Below is my original code. 

 

Kind regards, 

 

Niek

nvmierlo_0-1649324726234.png

 

nvmierlo_1-1649324726238.png

 

Dim oDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDoc.ActiveSheet
Dim oTO As TransientObjects = ThisApplication.TransientObjects
Dim oBalloons As Balloons = oSheet.Balloons
Dim oBalloon As Balloon
Dim oView As DrawingView = ActiveSheet.View("ISO").View 
Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("Ondersteuning:1") 
Dim view_ISO = Sheet_1.DrawingViews.ItemByName("ISO")

'Definition of number of values in array
Dim numImportIntents As Integer = 2 ' Aantal named geometries te importeren uit assembly, begint bij 0. één extra oInten(x) betekend numImportIntents +1 

'Creation of different arrays 
Dim oTG(numImportIntents) As TransientGeometry
Dim oLeaderPoints(numImportIntents) As ObjectCollection
Dim oIntent(numImportIntents) As Inventor.GeometryIntent

'Refrencing of named geometry in each compontent. 
oIntent(0) = view_ISO.GetIntent("Staander links", "Balloon", PointIntentEnum.kMidPointIntent)
oIntent(1) = view_ISO.GetIntent("Bovenligger", "Balloon", PointIntentEnum.kMidPointIntent)
oIntent(2) = view_ISO.GetIntent("Eindkap links", "Balloon", PointIntentEnum.kMidPointIntent)

 
For i = LBound(oTG) To UBound(oTG)
	oTG(i) = ThisApplication.TransientGeometry
Next 
For i = LBound(oLeaderPoints) To UBound(oLeaderPoints)
	oLeaderPoints(i) = ThisApplication.TransientObjects.CreateObjectCollection
Next

'Definition of location of balloon 1 
oLeaderPoints(0).Add(oTG(0).CreatePoint2d(oView.Left - 2, oView.Top + 1.5))
oLeaderPoints(0).Add(oIntent(0))
'Creation of balloon
oBalloon = oBalloons.Add(oLeaderPoints(0))

'2nd balloon 
oLeaderPoints(1).Add(oTG(1).CreatePoint2d(oView.Left -2 , oView.Top ))
oLeaderPoints(1).Add(oIntent(1))
oBalloon = oBalloons.Add(oLeaderPoints(1))

'3rd ballon
oLeaderPoints(2).Add(oTG(2).CreatePoint2d(oView.Left -2 , oView.Top - 1.5))
oLeaderPoints(2).Add(oIntent(2))
oBalloon = oBalloons.Add(oLeaderPoints(2))

 

 

Reply
Accepted solutions (1)
2,297 Views
10 Replies
Replies (10)

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

Without your drawing file and the referenced model, it's hard to replay. No one wants to create a similar model from scratch. I assume the NamedEntites are Edges and the components are not in any subassembly.

A straight and possible unstable way could be:

Dim oDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDoc.ActiveSheet
Dim oTO As TransientObjects = ThisApplication.TransientObjects
Dim oBalloons As Balloons = oSheet.Balloons
Dim oBalloon As Balloon
Dim oView As DrawingView = ActiveSheet.View("ISO").View 
Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("Ondersteuning:1") 
Dim view_ISO = Sheet_1.DrawingViews.ItemByName("ISO")

'Definition of number of values in array
Dim numImportIntents As Integer = 2 ' Aantal named geometries te importeren uit assembly, begint bij 0. één extra oInten(x) betekend numImportIntents +1 

'Creation of different arrays 
Dim oTG(numImportIntents) As TransientGeometry
Dim oLeaderPoints(numImportIntents) As ObjectCollection
Dim oIntent(numImportIntents) As Inventor.GeometryIntent

'Refrencing of named geometry in each compontent. 
oIntent(0) = view_ISO.GetIntent("Staander links", "Balloon", PointIntentEnum.kMidPointIntent)
oIntent(1) = view_ISO.GetIntent("Bovenligger", "Balloon", PointIntentEnum.kMidPointIntent)
oIntent(2) = view_ISO.GetIntent("Eindkap links", "Balloon", PointIntentEnum.kMidPointIntent)

For i = LBound(oTG) To UBound(oTG)
	oTG(i) = ThisApplication.TransientGeometry
Next 
For i = LBound(oLeaderPoints) To UBound(oLeaderPoints)
	oLeaderPoints(i) = ThisApplication.TransientObjects.CreateObjectCollection
Next

'Definition of location of balloon 1 
oLeaderPoints(0).Add(oTG(0).CreatePoint2d(oView.Left - 2, oView.Top + 1.5))
oLeaderPoints(0).Add(oIntent(0))
'Creation of balloon
oBalloon = oBalloons.Add(oLeaderPoints(0))

'#### added begin
Dim oBVSets As BalloonValueSets = oBalloon.BalloonValueSets

'the straight way
oBVSets.Add(ointent(1).Geometry.modelgeometry.containingoccurrence)
oBVSets.Add(ointent(2).Geometry.modelgeometry.containingoccurrence)

'#### added end


''2nd balloon 
'oLeaderPoints(1).Add(oTG(1).CreatePoint2d(oView.Left -2 , oView.Top ))
'oLeaderPoints(1).Add(oIntent(1))
'oBalloon = oBalloons.Add(oLeaderPoints(1))

''3rd ballon
'oLeaderPoints(2).Add(oTG(2).CreatePoint2d(oView.Left -2 , oView.Top - 1.5))
'oLeaderPoints(2).Add(oIntent(2))
'oBalloon = oBalloons.Add(oLeaderPoints(2))

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes

nvmierlo
Contributor
Contributor

Dear R. Krieg, 

 

Thank you very much your solution works flawlessly! 

0 Likes

nvmierlo
Contributor
Contributor

 @Ralf_Krieg 

Dear R. Krieg,

 

One small addition, would it also be possible to refer to the components of the extra balloons by their name in the model tree? So, that it is not necessary to create named geometry for those files

 

Once again, thank you in advance!

0 Likes

Ralf_Krieg
Advisor
Advisor

Hello

 

yes, for instance with the ComponentOccurrecnce names:

'#### added begin
Dim oBVSets As BalloonValueSets = oBalloon.BalloonValueSets

'the straight way
'oBVSets.Add(ointent(1).Geometry.modelgeometry.containingoccurrence)
'oBVSets.Add(ointent(2).Geometry.modelgeometry.containingoccurrence)

'alternative way using ComponentOccurrence names
Dim oModelDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument 
Dim oOcc As ComponentOccurrence
For Each oocc In oModelDoc.ComponentDefinition.Occurrences
	If oOcc.Name="Bovenligger" Or oOcc.Name="Eindkap links"
		oBVSets.Add(oOcc)
	End If
Next

'#### added end

R. Krieg
RKW Solutions
www.rkw-solutions.com

nvmierlo
Contributor
Contributor

Hello, 

 

that works great aswell. Thanks a lot!

0 Likes

nvmierlo
Contributor
Contributor

Dear R.Krieg, 

 

Here I am once more with another problem I am running into, is it also possible to refer tot components in sub assembly when using the method with component occurences? for example, I want to add a balloon for the component "DIN125 M6" that is part of the sub assembly "Type 1" (The sub assembly is structered Phantom in the main assembly). Thank you in advance once more. 

 

Kind regards,

 

Niek 

0 Likes

Ralf_Krieg
Advisor
Advisor

Hello

 

You can try using the AllLeafOccurrences which returns all Occurrences with no child occurrences. This could be afaik parts or empty assemblies.

Not sure it'll work, can't test right now.

'#### added begin
Dim oBVSets As BalloonValueSets = oBalloon.BalloonValueSets

'the straight way
'oBVSets.Add(ointent(1).Geometry.modelgeometry.containingoccurrence)
'oBVSets.Add(ointent(2).Geometry.modelgeometry.containingoccurrence)

'alternative way using ComponentOccurrence names
Dim oModelDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument 
Dim oOcc As ComponentOccurrence
For Each oOcc In oModelDoc.ComponentDefinition.Occurrences.AllLeafOccurrences
	If oOcc.Name="Bovenligger" Or oOcc.Name="Eindkap links"
		oBVSets.Add(oOcc)
	End If
Next

'#### added end

 


R. Krieg
RKW Solutions
www.rkw-solutions.com

nvmierlo
Contributor
Contributor

Dear R. Krieg, 

 

This works until a subassembly is present more than once in the main assembly, the rule then adds the sub component balloons to the orginal balloons for the amount of times the sub assembly occurs. 

 

image.png

 

Kind regards, 

 

Niek

0 Likes

Ralf_Krieg
Advisor
Advisor

Hello

 

We can simply try to write every Occurrence name added to the BalloonValueSet in a list and skip the next occurence with same name.

 

'#### added begin
Dim oBVSetList As New List (Of String)
Dim oBVSets As BalloonValueSets = oBalloon.BalloonValueSets

'the straight way
'oBVSets.Add(ointent(1).Geometry.modelgeometry.containingoccurrence)
'oBVSets.Add(ointent(2).Geometry.modelgeometry.containingoccurrence)

'alternative way using ComponentOccurrence names
Dim oModelDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument 
Dim oOcc As ComponentOccurrence
For Each oOcc In oModelDoc.ComponentDefinition.Occurrences.AllLeafOccurrences
	If oOcc.Name="Bovenligger" Or oOcc.Name="Eindkap links"
		If Not oBVSetList.Contains(oOcc.Name)
			oBVSets.Add(oOcc)
			oBVSetList.Add(oOcc.Name)
		End If
	End If
Next

'#### added end

R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes

nvmierlo
Contributor
Contributor

That once again worked, thank you!

0 Likes