Hi Victoria,
The following recursive script will hide all bodies except the name supplied as second argument:
def hide_all_bodies_except_one(comp: adsk.fusion.Component, body_name: str):
for body in comp.bRepBodies:
if body.name != body_name:
body.isLightBulbOn = False
for occ in comp.occurrences:
if occ.component:
hide_all_bodies_except_one(occ.component, body_name)
You can call it like:
hide_all_bodies_except_one(root, "Body6")
In this case it will hide all bodies except the ones with name "Body6".
It wont check if the body is visible or not, which could also be added. As a reminder a body is visible if itself has bulb on and also all its parent component are also visible.
Does this met your needs?
I hope this could help you.
Regards,
Jorge Jaramillo