-
-
August 8, 2023 at 6:28 am
Tobias Zeller
SubscriberHey everyone,
so I got a big API-Code where I'm importing a Step file. The Step-file is 2D surface body. Unfortunately, however, the dimension is not recognized correctly during import and set to 3D. Now, I would like to change the whole thing afterward to 2D or "Model2DBehavior.PlaneStress". I found in the other topic that
"body.Behavior = Model2DBehavior.PlaneStress" should be the key, but I can't access that via:
ExtAPI.DataModel.Project.Model.Geometry.Bodies
I'm really thankful for any help. -
August 8, 2023 at 6:39 am
Erik Kostson
Ansys EmployeeÂ
Â
Â
HI
The easiest is just to go to the system and change under the Geometry/Properties, the Analysis Type to 2D.
As for your question related to mechanical scripting:
You need another line to set dimensions to 2D:
Â
    Body.Dimension=ShellBodyDimension.Two_D
    Body.Behavior=Model2DBehavior.PlaneStrainAll the best
Erik
Â
Â
Â
-
August 8, 2023 at 6:57 am
Tobias Zeller
Subscriber@Erik Kostson
thanks a lot for your idea. Unfortunately, this is not working for me.
If I try: "ExtAPI.DataModel.Project.Model.Geometry.Body.Dimension=ShellBodyDimension.Two_D" it's saying "'Geometry' object has no attribute 'Body' ".
And if I try: "ExtAPI.DataModel.Project.Model.Geometry.Bodies.Dimension=ShellBodyDimension.Two_D" is saying " 'int' object has no attribute 'Dimension' " as "Bodies" resullts in an int-value.
Am I missing something minor?
Thanks a lot! -
August 8, 2023 at 7:09 am
Erik Kostson
Ansys EmployeeÂ
HI
So this works (2023 R1 and R2):
model = ExtAPI.DataModel.Project.Model
Parts = model.Geometry.GetChildren(DataModelObjectCategory.Part,True)
for Part in Parts:
  for Body in Part.Children:
    print(Body.Name)
    Body.Dimension=ShellBodyDimension.Two_D
    Body.Behavior=Model2DBehavior.PlaneStrainSee the ACT Start Page for examples on how to loop and get geometry.
Closing the post.
Erik
Â
-
- The topic ‘Changing Body Dimension in API’ is closed to new replies.
-
3492
-
1057
-
1051
-
965
-
942
© 2025 Copyright ANSYS, Inc. All rights reserved.