How to change certain Keyoptions only for Solid bodies in my Mechanical model?
Rohith Patchigolla
Member, Moderator, Employee Posts: 193
✭✭✭✭
in Structures
In my Mechanical model, I have large number of both solid and shell bodies. I would like to change the keyoption(2) --2, for all the solid bodies (linear mesh) to use Enhanced Strain Formulation. I would like to avoid adding 100s of command objects (i.e. under each solid body). Is there an easier way to do this?
Tagged:
0
Comments
-
This can be made easier using Python Code object.
Step1: RMB on Analysis and insert a "Python Code" object
Step2: Add the below code in it, which will extract all the solid bodies and change the keyoption 2 to 2 for each body.Note: This process will not work if one uses "Material Assignments" in Mechanical
#Execute the below commands only in the First load step. if solver_data.CurrentStep == 1: #Enter /Prep7 solver_input_file.WriteLine("/prep7") solver_input_file.WriteLine("etcontrol,off") #Get all bodies and loop over them to change Keyoption 2 to 2 (Enhanced Strain) allBodies = DataModel.GetObjectsByType(DataModelObjectCategory.Body) solidBodies = [child for child in allBodies if child.GetGeoBody().BodyType == GeoBodyTypeEnum.GeoBodySolid] for body in solidBodies: bodyTypeNum = solver_data.GetMaterialSolverId(body.GetGeoBody().Id) solver_input_file.WriteLine("keyopt," + str(bodyTypeNum) + ",2,2") #Enter /solu again solver_input_file.WriteLine("/solu")
1