Some solutions like https://discuss.ansys.com/discussion/2468/beam-results-dpf-mechanical mention the following line to select Beams in a mechanical model:
allBeams = DataModel.GetObjectsByType(DataModelObjectCategory.Beam)
This doesn't work for me in 24R1 even though the model has only beams present in it.
I have run the following script to find out what the DataModelObjectCategory is for beam elements:
assm=DataModel.GeoData.Assemblies
for my_assm in assm:
for part in my_assm.AllParts:
for body in part.Bodies:
if body.Suppressed==False:
#body is a GeoBodyWrapper
print(body.Name+" ("+str(body.GetType())+";"+str(body.BodyType)+")")
#Get true body object instead of GeoBodyWrapper so that DataModelObjectCategory can be checked
#From: https://discuss.ansys.com/discussion/2361/getting-a-mechanical-body-from-a-geometry-geobodywrapper
true_body=DataModel.Project.Model.Geometry.GetBody(body)
#Next line shows that a beam has DataModelObjectCategory==Body instead of Beam
print('DataModelObjectCategory= '+str(true_body.DataModelObjectCategory)+"; "+\
str(true_body.CrossSectionSelection.DataModelObjectCategory)+"; "+\
str(true_body.GeometryType))
The output shows that beam bodies have Body as DataModelObjectCategory and not Beam:
Beam (Bulb Profile L Equivalent) (Ansys.ACT.Common.Geometry.GeoBodyWrapper;GeoBodyWire)
DataModelObjectCategory= Body; ZCrossSection; Line
Beam (Bulb Profile L Equivalent) (Ansys.ACT.Common.Geometry.GeoBodyWrapper;GeoBodyWire)
DataModelObjectCategory= Body; ICrossSection; Line
Beam (Bulb Profile L Equivalent) (Ansys.ACT.Common.Geometry.GeoBodyWrapper;GeoBodyWire)
DataModelObjectCategory= Body; TCrossSection; Line
Beam (Bulb Profile L Equivalent) (Ansys.ACT.Common.Geometry.GeoBodyWrapper;GeoBodyWire)
DataModelObjectCategory= Body; CircularTubeCrossSection; Line
Beam (Bulb Profile L Equivalent) (Ansys.ACT.Common.Geometry.GeoBodyWrapper;GeoBodyWire)
DataModelObjectCategory= Body; LCrossSection; Line
My questions are:
1. Which type of bodies have the DataModelObjectCategory=Beam?
2. How can one easily select all beams in a model when selecting based on DataModelObjectCategory doesn't work?