Ansys Learning Forum › Forums › Discuss Simulation › 3D Design › Python API: Setting object visibility from selection › Reply To: Python API: Setting object visibility from selection
July 5, 2023 at 6:20 pm
Sterling Butters
Subscriber
@Aniket
Sorry, I did not clarify that I did not provide the body name (since it is variable/changing).Â
I was able to get it working with:
selection = Selection.Create([body for body in GetRootPart().GetAllBodies() if body.Parent.GetName() == ComponentName])
  visibility = VisibilityType.Show
  inSelectedView = False
  faceLevel = False
  ViewHelper.SetObjectVisibility(selection, visibility, inSelectedView, faceLevel)
Which I think implements the logic suggested by @mjmiddle
Thanks!