By Florentina Stirbu
There are multiple ways of replacing an assembly component via iLogic. In this scenario, I want to get multiple variations of a lamp assembly by selecting the body and shade type from a form.
I’ve added 2 multi-selection text parameters (ShadeType and BodyType) to my assembly with values to correspond to each body/shade type and then created a form using these parameters:
When building the iLogic rule to replace the components, using component.replace() requires the name of the existing component and the name of the new one. When the component is changed, the name of the new component will be displayed in the model browser, causing the rule to fail for further iterations with an error stating : Component: The component named "initial name" was not found.
In order to repeatedly change the body and shade as controlled by the form, I’ve written 2 version of the rule:
1. Rename the components in the browser so that their name won’t change after replacing:
The lamp assembly currently has “Body3.ipt” and “Shade3.ipt” as components. If I rename them to “Body” and “Shade”, I can reference them in the rule below:
2. Get the name from the browser
This version of the code gets the component name by its position in the model tree, which is helpful as the name changes when replacing.
Below you can see the code in action: