Get body in tree from selected face
Pernelle Marone-Hitz
Member, Moderator, Employee Posts: 871
✭✭✭✭
I've selected a face manually in Mechanical and would like to know to which body in the Mechanical tree it corresponds to.
Tagged:
0
Answers
-
If a face is selected manually then its geoid can be retrieved through the selection manager with:
face_sel = ExtAPI.SelectionManager.CurrentSelection
face_sel contains a list of Ids of the selected geo-entities. If only one face is selected we can assume that face_sel is a list of only one element. In this case, the geobody corresponding to this selected face can be obtained through:
my_geobody = geoData.GeoEntityById(face_sel.Ids[0]).Bodies[0]
And finally the object in the tree can be obtained with:
my_tree_body = ExtAPI.DataModel.Project.Model.Geometry.GetBody(my_geobody)
6