Hi. I’m writing a script that includes a list of components. When a new component is brought to the 3D world, is there any way to automatically add the component to the script? Wondering this because the simulation has multiple identical components but the amount of the components may vary while testing different scenarios. So this would decrease the amount of manual work.
I found out that all components can be stored in a list by using app.Components. Is it possible to store same category items in a list the same way?
You could use the property “Category” of the components to create your list, somthing like :
list = [c for c in app.Components if c.Category == “CategoryName”] ?
There is an application event “OnComponentAdded” which could maybe help you :
https://help.visualcomponents.com/4.9/Premium/en/Python_API/vcApplication.htm
Thanks! This helped a lot.
Hi @jeyjey
Yes, you can automate adding components to your script by using an event listener or callback function in your 3D engine. When a new component is instantiated or added to the scene, the event listener can trigger a function that automatically updates your script with the new component’s details. This way, you can dynamically handle varying numbers of components without manual updates.
Thanks