Using Rules to replace a subassembly

Using Rules to replace a subassembly

Anonymous
Not applicable
759 Views
4 Replies
Message 1 of 5

Using Rules to replace a subassembly

Anonymous
Not applicable

I have a top level assembly that consists of two sub assemblies, one that has two variations, one that has 3 variations.  I want to swap the subassemblies based on conditions that are set up in a linked Excel Spreadsheet.  In other words, based on certain factors defined in the spreadsheet I want to swap the sub assemblies with other subassemblies that have been updated to meet the criteria specified in the spreadsheet.

0 Likes
760 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

you can use the Component.Replace function

 

if paramA = 1 then

Component.Repace("initial subassembly", " new  subassembly.iam",False)

end if

 

You need to stabalize  the initial subassembly name in the Inv browser

False replaces the first occurence, use True to replace all occurences

The initial subassembly must be placed using imates and the new subassenbly must have matching imates for the replace to work properly

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

"You need to stabalize  the initial subassembly name in the Inv browser

False replaces the first occurence, use True to replace all occurences

The initial subassembly must be placed using imates and the new subassenbly must have matching imates for the replace to work properly"

Can you explain what you mean by Stabalize the initial subassembly name?  I'm also a little unclear on the difference between False and True.  If the subassembly occurs only once in the assembly I am to use "False"?  I have two subassemblies, one called "Master Chamber_With Tabs.iam" and one called "Master Chamber_With Tabs_Half Wall.iam".  I want to automatically replace one with the other when certain values in the spreadsheet are true.  So I am to prepare the rule like the following:

Component.Replace("Master Chamber_With Tabs:1", "Master Chamber_With Tabs_Half Wall.iam", False)

 

0 Likes
Message 4 of 5

Anonymous
Not applicable

okay, lets look at your code

Component.Replace("Master Chamber_With Tabs:1", "Master Chamber_With Tabs_Half Wall.iam", False)

 

when the code runs the first time Master Chamber_With Tabs:1 would be replaced, however if you ran the code a second time it would fail since Master Chamber_With Tabs:1 will not be found (since it has been replaced)

Therefore you have to "stabalize"  the occurence name

 

Do this

Assemble Master Chamber_With Tabs:1 into your upper level assembly

find Master Chamber_With Tabs:1 in your Inventor browser , and rename it to something else meaningful like Master Chamber Option:1

then change your rule to read

Component.Replace("Master Chamber Option:1", "Master Chamber_With Tabs_Half Wall.iam", False)

 

then your code will work every time since it will always find the "stabalized" occurence name

 

if you only have one occurance of the sub assembly then either True or False will do the same thing

It only makes a difference if you have multiple instances and want to control only certain ones

0 Likes
Message 5 of 5

Anonymous
Not applicable

This worked perfectly, thank you.  

0 Likes