placing and constraining an item with iLogic

placing and constraining an item with iLogic

Anonymous
Not applicable
687 Views
6 Replies
Message 1 of 7

placing and constraining an item with iLogic

Anonymous
Not applicable

Good Day,

 

i was wondering if there was a way to place a component into an assembly and constrain it purely with ilogic, without any human interaction?  and if so how?

 

Thanks in advance 🙂

0 Likes
Accepted solutions (1)
688 Views
6 Replies
Replies (6)
Message 2 of 7

JelteDeJong
Mentor
Mentor
Accepted solution

That is possible. Adding a part to a assembly is not a problem. see this rule:

 

Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim matrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix()
Dim occurrence As ComponentOccurrence = oDoc.ComponentDefinition.Occurrences.Add("C:\temp\flange.ipt", matrix)

Constraining is also possible but is much more dificult. you can have a look at the help files. in the help files there are also examples

 

 

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 7

Yijiang.Cai
Autodesk
Autodesk

@Anonymous , If you are using inventor 2019/2020, you could easily get the code samples on placing & constraining a components. Please see the image below. It should work for you.

Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
Message 4 of 7

Anonymous
Not applicable

Thank you so much!

Your solution worked perfectly for placing the component.

 

 

0 Likes
Message 5 of 7

Anonymous
Not applicable

This example worked perfectly for placing a component into the top level of a model.

Is there way to place a component into a sub assembly where the rule is run?

0 Likes
Message 6 of 7

Yijiang.Cai
Autodesk
Autodesk

You could use the code lines below -

Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim matrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix()

Dim oDef As ComponentDefinition
oDef = oDoc.ComponentDefinition.Occurrences(1).Definition '1: we use the first sub-assembly to add the component, and you could pick the right one

odef.Occurrences.Add("C:\temp\part1.ipt", matrix)
Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
Message 7 of 7

Anonymous
Not applicable

Thank you for your reply, but is there a way to go directly to the sub assembly by name?

0 Likes