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)