Get Tree Object of a Body Corresponding to a Selected Body

Goal: Get the tree object corresponding to a selected body in the Mechanical graphics window.

Code:

myIds = ExtAPI.SelectionManager.CurrentSelection.Ids
geoBody = ExtAPI.DataModel.GeoData.GeoEntityById(myIds[0])
treeBody = ExtAPI.DataModel.Project.Model.Geometry.GetBody(geoBody)

Release 18.2 - © ANSYS, Inc. All rights reserved.