Parent/child components

Parent/child components

jimsiega
Explorer Explorer
309 Views
2 Replies
Message 1 of 3

Parent/child components

jimsiega
Explorer
Explorer

I would like to use the api to find all children components of a parent so that I can rename component only in parent.  I can't see anything in the api that references a parent component.  I have been referencing the component object section in the api.

 

thanks

jim

0 Likes
310 Views
2 Replies
Replies (2)
Message 2 of 3

j4n.vokurka
Advocate
Advocate

Hello,

maybe it would help to clarify the terminology a bit here. If we speak about components, each component is unique meaning it is defined somewhere and when we use it in a model we create new occurrence (instance basically) of this component. 

That way we can create multiple occurrences of the same component and in the view tree you can identify these instances and their one mutual component by their names:

j4nvokurka_0-1708522939250.png

You can see each occurrence has a colon with a number appended to it. This number tells you as what instance of the given component the occurrence was added into the model. For example "Connecting Rod:3" was the 3rd occurrence of component "Connecting Rod" added into this model.

Note: if you paste the component into different model the numbering will start again from 1 as it only references the current model.

Now to your question, if I understand it correctly you want to change the name of the component so all the occurrences' names will change as well. In that case you can just call name() on your component and paste a string as argument. That string will become the new name of the component. Just remember that the occurrences will still be numbered in the model even though you have set a new name to the component. 

I hope I answered your question and this wasn't a waste of time 🙂


Message 3 of 3

jimsiega
Explorer
Explorer

Thank you for you clear response.  I have managed to achieve the result.

0 Likes