Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
General Mechanical

General Mechanical

Topics related to Mechanical Enterprise, Motion, Additive Print and more.

Changing Body Dimension in API

TAGGED: ,

    • Tobias Zeller
      Subscriber

      Hey 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.

    • ErKo
      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.PlaneStrain

      All the best

      Erik

       

       

       

    • 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!

    • ErKo
      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.PlaneStrain

      See the ACT Start Page for examples on how to loop and get geometry.

      Closing the post.

      Erik

       

Viewing 3 reply threads
  • The topic ‘Changing Body Dimension in API’ is closed to new replies.
[bingo_chatbox]