July 3, 2023 at 6:50 pm
Ansys Employee
There are several problems in that first section:
- You forgot a dot (".") between GetRootPart() and GetComponents()
- A body is not a component. Maybe this was just a naming convention you were using in your script, because you can turn on/off visibility of components the same way as bodies. But you could have just as well named your variable i_component instead of i_body to be more clear, but it's just a variable name. However, if you intended to get bodies, you can get all bodies this with GetRootPart().GetAllBodies(). Or to get a body within a component (1st component in this case), go through the "Content" object: GetRootPart().Components[0].Content.Bodies. To get a component by name: comp = GetRootPart().GetComponents(comp_name)[0].
- An Aniket mentioned, bodies in SpaceClaim cannot exist without a name, so searching for bodies with blank names is not a sensible strategy.