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
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))
Solved! Go to Solution.
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
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))
Solved! Go to Solution.
Solved by Ralf_Krieg. Go to 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))
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))
Dear R. Krieg,
Thank you very much your solution works flawlessly!
Dear R. Krieg,
Thank you very much your solution works flawlessly!
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!
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!
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
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
Hello,
that works great aswell. Thanks a lot!
Hello,
that works great aswell. Thanks a lot!
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
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
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
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
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.
Kind regards,
Niek
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.
Kind regards,
Niek
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
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
That once again worked, thank you!
That once again worked, thank you!
Can't find what you're looking for? Ask the community or share your knowledge.