Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic to organize balloons and weld symbols on a drawing

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
Anonymous
1725 Views, 11 Replies

iLogic to organize balloons and weld symbols on a drawing

I am setting up some drawings for automation and I have the dimension offsets automated with the below. I am looking to see if there is a way to get the balloons/weld symbols/maybe even text with leaders to all snap automatically into position in a similar way.

 

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet
Dim oDrawingDim As DrawingDimension
Dim oDrawingDims As DrawingDimensions
Dim oDimsToBeArranged As ObjectCollection
oDrawingDimensions=oSheet.DrawingDimensions
oDimsToBeArranged = ThisApplication.TransientObjects.CreateObjectCollection
For Each oDrawingDim In oDrawingDimensions
    If TypeOf oDrawingDim Is LinearGeneralDimension Then 'Or TypeOf oDrawingDim Is AngularGeneralDimension Then
    	oDrawingDim.CenterText
    	oDimsToBeArranged.Add(oDrawingDim)
    End If
Next
oDrawingDimensions.Arrange(oDimsToBeArranged)
11 REPLIES 11
Message 2 of 12
clutsa
in reply to: Anonymous

Here is the code I use to move the balloons to the top of my view (only up or down not left to right)

viewName = "FRONT" 'change to match your views name
ActiveSheet.View(viewName).Balloons.Reattach 
tg = ThisServer.TransientGeometry
Dim oBalloon As Balloon
Dim oLeader As LeaderNode
For Each iBalloon In ThisDrawing.Document.ActiveSheet.Balloons
	oBalloon = iBalloon
	If Not oBalloon.Layer.Name = "PlugBalloon" Then 'only needed if you have balloons you dont want to have move
			XPos = oBalloon.Position.X
		oBalloon.Position = tg.CreatePoint2d(XPos, ActiveSheet.View(viewName).View.Top + 1)
	End If
Next

At this time I am not aware of any API interface to even begin to play with weld symbols. Smiley Sad 

but there are ideas to add them so please like them to help get it added

https://forums.autodesk.com/t5/inventor-ideas/weld-symbols-exposed-in-the-api-in-assemblies/idi-p/65...

 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State
Message 3 of 12
Anonymous
in reply to: clutsa


@clutsa wrote:

Here is the code I use to move the balloons to the top of my view (only up or down not left to right)

viewName = "FRONT" 'change to match your views name
ActiveSheet.View(viewName).Balloons.Reattach 
tg = ThisServer.TransientGeometry
Dim oBalloon As Balloon
Dim oLeader As LeaderNode
For Each iBalloon In ThisDrawing.Document.ActiveSheet.Balloons
	oBalloon = iBalloon
	If Not oBalloon.Layer.Name = "PlugBalloon" Then 'only needed if you have balloons you dont want to have move
			XPos = oBalloon.Position.X
		oBalloon.Position = tg.CreatePoint2d(XPos, ActiveSheet.View(viewName).View.Top + 1)
	End If
Next

At this time I am not aware of any API interface to even begin to play with weld symbols. Smiley Sad 

but there are ideas to add them so please like them to help get it added

https://forums.autodesk.com/t5/inventor-ideas/weld-symbols-exposed-in-the-api-in-assemblies/idi-p/65...

 


While not quite what I was hoping for, I could move all the balloons in a similar way. Since I need them to go in different directions, I will probably have to manually figure it out for each balloon and then give each a separate line of code for positioning. It will be a little clunky to do, but the end result will probably be better than hoping that the automation would space them out properly.

 

Additionally, I found a work around for the weld symbols in another thread, but I will try to position them so as things move they should always clear the geometry and not have any overlap.

Message 4 of 12
clutsa
in reply to: Anonymous

Could you put the balloons on different layers named "Top", "Left", "Right", "Bottom"  then move them around the view based on their layer?  (much like I did to skip some balloons)

The other thing you could try but would take some real thinking, is to create a sketch on a layer that doesn't print. Then move the balloons so that they always fell on that sketches lines. (I like that idea so much I may try to figure it out for myself when I get my current project done)

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State
Message 5 of 12
Anonymous
in reply to: clutsa

That could work, but because my assembly changes mostly in diameter, the bubbles shift left and right relative to each other. If I give each a line specifically dedicated to it, I can keep them from hitting a dimension line, and keep them separated by the same offset. The sketch idea is interesting, but just moving things outwards means you may need to manually shift them so that the offset between them is consistent. The ability to dodge the dimensions which will have predictable locations due to the dimension arrangement button/command is probably the most important part of this to me.

Message 6 of 12
clutsa
in reply to: Anonymous

Would you be able to share a screen shot from a drawing? I have other code that moves balloons left and right based on proximity to workpoints in the model but it's a bit complicated (at least to explain) a reference to what you're talking about may help me point you in the right direction. (or let me leave out code that is irrelevant and like to cause confusion)

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State
Message 7 of 12
Anonymous
in reply to: clutsa

Unfortunately everything is proprietary and I can't really share any of it. I have some basic code in there that always snaps the bubbles to the edges whenever it cleans up the dimensions. Basically it moves specific bubbles to given spots is define as a given corner of the view plus some coordinate offset It wasn't what i was originally hoping for, but it works so I am not complaining. If the welds don't want to behave all the time, i'll have to use that sketch method, but so far, it all works.

Message 8 of 12
dominik.kubicek
in reply to: clutsa

Hi everyone here,

I want to share my issue related to balloons organizing and hope someone can find what is wrong.
I try to iterate through all the balloons on my drawing and compare its values, so I can then identify and delete those with same value (we use another iLogic rule, what thanks to attribute helper create all of the balloons, but some of them are doubled/tripled, based on the product configuration). Because the rule for balloons creation is quite complex now, we want to keep this new rule for deletion of multiple-time-inserted balloons alone.

 

This is what I have so far, but the rule stops after the first "If" statement for deletion is true and end up with an error - incorrect parameter.

 

 

 

Sub Main()
Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.Sheets.Item(1)
'Dim pocetPozic As Integer = oSheet.Balloons.Count

For i = 1 To oSheet.Balloons.Count
' MessageBox.Show(oSheet.Balloons.Count, "pocet pozic na vykrese")
Dim balValueI As Integer = oSheet.Balloons.Item(i).BalloonValueSets.Item(1).Value
MessageBox.Show(oSheet.Balloons.Item(i).BalloonValueSets.Item(1).Value, "hodnota pozice I")

For j = 1 To oSheet.Balloons.Count
If j = i Then Continue For
Dim balValueJ As Integer = oSheet.Balloons.Item(j).BalloonValueSets.Item(1).Value
' MessageBox.Show(oSheet.Balloons.Item(j).BalloonValueSets.Item(1).Value, "hodnota pozice J")
If balValueI = balValueJ Then
oSheet.Balloons.Item(j).Delete
' MessageBox.Show(oSheet.Balloons.Count.ToString, "pocet pozic na vykrese")
End If
Next
Next
End Sub

 

 

 

Thanks to anyone willing to help.

Dominik.

Message 9 of 12
clutsa
in reply to: dominik.kubicek

You're doing a loop for the number of balloons on the sheet but then changing the number of balloons so by the time you get to i = 9 you only have 8 balloons left. You don't have an item(i) left to compare.

Sub Main()
Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.Sheets.Item(1)
'Dim pocetPozic As Integer = oSheet.Balloons.Count

For i = 1 To oSheet.Balloons.Count
	If i<= oSheet.Balloons.Count
		' MessageBox.Show(oSheet.Balloons.Count, "pocet pozic na vykrese")
		Dim balValueI As Integer = oSheet.Balloons.Item(i).BalloonValueSets.Item(1).Value
		MessageBox.Show(oSheet.Balloons.Item(i).BalloonValueSets.Item(1).Value, "hodnota pozice I")

		For j = 1 To oSheet.Balloons.Count
			If j <= oSheet.Balloons.Count
				If j = i Then Continue For
					Dim balValueJ As Integer = oSheet.Balloons.Item(j).BalloonValueSets.Item(1).Value
					' MessageBox.Show(oSheet.Balloons.Item(j).BalloonValueSets.Item(1).Value, "hodnota pozice J")
					If balValueI = balValueJ Then
						oSheet.Balloons.Item(j).Delete
						' MessageBox.Show(oSheet.Balloons.Count.ToString, "pocet pozic na vykrese")
					End If
			End If
		Next
	End If
Next
End Sub
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State
Message 10 of 12
dominik.kubicek
in reply to: clutsa

Thank you @clutsa  a lot, I thought it was something with balloons count after the rule deleted some, but did not see what exactly. So If I understand it right, after removing some duplicated balloon, I logically have new .Count value, but Inventor still uses the default .Count value for "i" in a loop? If I have for example 10 balloons at the beginning and gradually remove lets say 5, Inventor would try to make a loop 10 times instead of just 5?

Regards, Dominik.

Message 11 of 12
clutsa
in reply to: dominik.kubicek

Exactly right! It's not just Inventor either, I used to have the same issue in Excel VBA. At the "For i = 0 to object.count" it sets object.count. Then at each "Next" it checks if "i" meets the condition to stop... you never get back to the "For" line. It's easily fixed by adding the "If i <= object.count then" so now you get to recheck the count on each loop. You could also use "If i > object.count then Exit For" 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State
Message 12 of 12
dominik.kubicek
in reply to: clutsa

thanks for clarification @clutsa , I am gonna put this note into my notebook about iLogic tips and tricks :). Your workaround works perfectly.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report