I have selected a face / body and know the ID of the item. How can I retrieve some mesh information like elements and nodes?
This can be achieved with some Python commands executed in the Mechanical Scripting interface.
First let's check how you can get the face / body Id. Assuming you've created a Named Selection scoped to the face(s) / body(ies), you can select that object and check the Ids of the scoped parts:
sel = DataModel.GetObjectsByName('NamedSelection')[0] selectionIds = sel.Ids
To get the element / node data, the mesh associated with the selected face / body must first be selected. In the case of a face with Id = 7 for example:
myFaceId = 7 meshData = ExtAPI.DataModel.Project.Model.Analyses[0].MeshData meshFace = meshData.MeshRegionById(myFaceId)
Then the element / node data can be retrieved from the meshFace object:
elementIdsMeshFace = meshFace.ElementIds elementIds = meshFace.ElementIds nodeIds = meshFace.NodeIds
To access the element / node objects themselves:
elements = meshFace.Elements nodes = meshFace.Nodes
To retrieve the X, Y, Z, coordinates of a selected node:
xLoc = nodes[0].X yLoc = nodes[0].Y zLoc = nodes[0].Z
In the case of bodies, the commands are exactly the same. To export the desired data to a text file, you can do so by using the usual Python commands with the 'os' library after importing it.