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.

Geometry Tree Body Thickness automation

    • thermalsr71
      Subscriber

      Hi, I'm doing a script that applies an arbitrary thickness to the parts of the geometry tree, depending on whether they are stored in a previously made dictionary or not.
      However, when I try to set the thickness manually, I'm getting the error:

      "expected Quantity, got float"

      If someone could help me understand the error or the way to convert a floating number into the so-called "Quantity", I'd be very grateful to you.

      My code goes:


       for key, values in partAndBody.items():
          for part in geom.Children:
              for body in part.Children: 
                          if values[2] == 'Plane Stress':
                              body.Behavior = Model2DBehavior.PlaneStress
                              body.Thickness = values[3]

      thank you in advance.

    • thermalsr71
      Subscriber

      Just found a way. Ansys works with its own particular data types. Had to declare my data as Quantity('{} [{}]'.format(values[3], 'mm')) and it worked!

    • ErKo
      Ansys Employee

      For further discusions on the quantity function and how to use it see:

      /forum/forums/topic/use-of-loop-in-python-scripting/

       

Viewing 2 reply threads
  • The topic ‘Geometry Tree Body Thickness automation’ is closed to new replies.
[bingo_chatbox]