In ACT, how can I print the material properties and values defined for each body in the Mechanical t
Pernelle Marone-Hitz
Member, Moderator, Employee Posts: 871
✭✭✭✭
In ACT, how can I print the material properties and values defined for each body in the Mechanical tree?
Tagged:
0
Answers
-
The following code can be used:
import materials bodies = ExtAPI.DataModel.Project.Model.GetChildren(DataModelObjectCategory.Body,True) # create list with all bodies in the Mechanical tree for body in bodies: # loop on all bodies in Mechanical Tree print(body.Name) # print body name geo_body = body.GetGeoBody() # get GeoData of this current body material = geo_body.Material # access material class for this geo body print(materials.GetListMaterialProperties(material)) # print material properties defined for this body properties = materials.GetMaterialPropertyByName(material,"Elasticity") # list values for Elasticity property print(properties) # print values
2 -
Actually you can loop directly through the bodies:
import materials bodies = ExtAPI.DataModel.Project.Model.GetChildren(DataModelObjectCategory.Body,True) # create list with all bodies in the Mechanical tree for body in bodies: #loop on all bodies in Mechanical Tree print(body.Name) # print body name current_geo_body=body.GetGeoBody() # get GeoData of this current body current_material=current_geo_body.Material # access material class for this geo body print(materials.GetListMaterialProperties(current_material)) # print material properties defined for this body current_properties=materials.GetMaterialPropertyByName(current_material,"Elasticity") # list values for Elasticity property print(current_properties) # print values
5