• Blog posts

    Bio

    By Florentina Stirbu

    Inventor_-_Replace_assembly_component_with_iLogic_-_1.JPG

    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:

    Inventor_-_Replace_assembly_component_with_iLogic_-_2.JPG

    Inventor_-_Replace_assembly_component_with_iLogic_-_3.JPG

    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:

    Inventor_-_Replace_assembly_component_with_iLogic_-_4.JPG

    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:

    Inventor_-_Replace_assembly_component_with_iLogic_-_6.JPG

    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.

    Inventor_-_Replace_assembly_component_with_iLogic_-_5.JPG

    Below you can see the code in action:

    Replace_assembly_component_with_iLogic_-_1.gif