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: 

Constrain to origin - selected parts

1 REPLY 1
Reply
Message 1 of 2
ANPGX2JT
94 Views, 1 Reply

Constrain to origin - selected parts

Hello,

 

Recently I stumbled across a handy tool which allows to constrain all the parts in an assembly to the origin (by grounding, measuring the distances to the origin planes and then applying the new constraints)

 

https://forums.autodesk.com/t5/inventor-programming-ilogic/auto-constrain-in-current-position-with-o...

 

However I thought that it would be good if there was an option to apply these changes only to selected parts, like in this post:

 

Dim comps As ObjectCollection
Dim comp As Object

comps = ThisApplication.TransientObjects.CreateObjectCollection

While True
	comp = ThisApplication.CommandManager.Pick(
		SelectionFilterEnum.kAssemblyOccurrenceFilter, 
		"Select a component") 
		
	' If nothing gets selected then we're done	
	If IsNothing(comp) Then Exit While
	
	comps.Add(comp) 
End While

' If there are selected components we can do something
For Each comp In comps
	comp.Delete()
Next

 

https://adndevblog.typepad.com/manufacturing/2013/11/do-selection-from-ilogic.html

However, my attempts to integrate it somehow in the initial code, substituting the original for loop failed - it either ended with error or just removed all the existing constraints;

 

if possible, could someone with deeper knowledge of iLogic and scripting suggest the proper way of adding it (if something like this can be performed of course)?

 

Thank you in advance for your help

1 REPLY 1
Message 2 of 2
A.Acheson
in reply to: ANPGX2JT

Hi @ANPGX2JT 

Can you attach your attempt here. It will give us a better understanding of what your atemmpting to do and also give you some pointers on where things may have gone wrong for you.

A tip for debugging. With lot of loops like this I like to remove the actuation portions of the code and just make sure you can target the correct occurrence name. So  comment off all other code operations and first return the correct occurrence names. Then reintroduce the operations one by one and check your result with a message box or logger statement. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report