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.
Ansys Products

Ansys Products

Discuss installation & licensing of our Ansys Teaching and Research products.

Read Ixx, Iyy and the Centroid of selected face using 19.2 scripting

    • Tom Ber
      Subscriber

      Hi,

      I would like to read the values of centroid and area moment of inertia Ixx and Iyy for selected faces. In version 22 this is possible using measureHelper, but I can't find these values in version 19.2. Is this possible also in older versions?

      ?

    • mjmiddle
      Ansys Employee

      This will not work for the face of a solid. Your face must be a surface body:

       

      body1 = GetRootPart().Bodies[0]
      #body1 = GetRootPart().Components[0].Content.Bodies[0].Master    # If body in component
      mass = body1.MassProperties.Mass
      volume = body1.Shape.Volume
      centroid = body1.MassProperties.PrincipleAxes.Origin
      totalSurfaceArea = body1.Shape.SurfaceArea
      principalXAxis = body1.MassProperties.PrincipleAxes.DirX
      principalYAxis = body1.MassProperties.PrincipleAxes.DirY
      principalZAxis = body1.MassProperties.PrincipleAxes.DirZ
      principalMomentXAxis = body1.MassProperties.GetMoment(body1.MassProperties.PrincipleAxes.AxisX)   # only matches when no material is assigned so that mass=0
      principalMomentYAxis = body1.MassProperties.GetMoment(body1.MassProperties.PrincipleAxes.AxisY)
      principalMomentZAxis = body1.MassProperties.GetMoment(body1.MassProperties.PrincipleAxes.AxisZ)


      If no material and width is assigned, you get area properties, not mass properties. 

    • Tom Ber
      Subscriber

      Perfect Thanks, this is exactly what I need.

      I also need to read the Ixy.

      I tried to use GetInertiaTensor(), but didn't get the right value.

      Could you help me with that too? Should I create new topic?  

       

    • mjmiddle
      Ansys Employee

      inertia = body1.MassProperties.GetInertiaTensor(body1.MassProperties.PrincipleAxes)
      inertia[0,0]    # 3x3 matrix. Since frame used principal axes, all entries are zero except the diagonal: [0,0], [1,1], [2,2]

    • Tom Ber
      Subscriber
      Hi mjmiddle,
      Thanks a lot for the answer. As i understand, If the body/face is not point-symmetric, then Ixy should be other than 0.
      Below I am sending you the code with the printed() values and the picture where you can see the values from "Mass Properties" tool. I wonder why the values read from Mass Properties are different from those read from GetInertiaTensor().
       
       
      selected_bodies = Selection.GetActive().Filter[IDesignBody]()
      Body1 = selected_bodies.Items[0]
      Centroid = Body1.MassProperties.PrincipleAxes.Origin
       
      Inertia_Tensor = Body1.MassProperties.GetInertiaTensor(Body1.MassProperties.PrincipleAxes)
       
      print("Centroid:{} mm".format(Centroid*1e3))
      Centroid:Point: (-3,07067122925524, 2,867257943362, 0) mm
      print("Ixx:{} mm^4".format(Inertia_Tensor[0,0]*1e12))
      Ixx:235733.0278 mm^4
      print("Iyy:{} mm^4".format(Inertia_Tensor[1,1]*1e12))
      Iyy:692513.5556 mm^4
      print("Izz:{} mm^4".format(Inertia_Tensor[2,2]*1e12))
      Izz:928246.5834 mm^4
       
      print("Ixy:{} mm^4".format(Inertia_Tensor[0,1]*1e12))
      Ixy:0.0 mm^4
      print("Ixz:{} mm^4".format(Inertia_Tensor[0,2]*1e12))
      Ixz:0.0 mm^4

       

       

    • mjmiddle
      Ansys Employee

      Principal axes through the centroid should have zero terms for the product of inertia terms. The argument in the command is a Frame:

      Inertia_Tensor = Body1.MassProperties.GetInertiaTensor(Body1.MassProperties.PrincipleAxes)

      The Body1.MassProperties.PrincipleAxes is a Frame with principal axes all going through the body origin. If you create a different frame not going through origin, the product of inertia terms will be non-zero.

      For the non-matching value to the GUI printout, see the comment in the code I sent:

      # only matches when no material is assigned so that mass=0

      So the values given by code are volume and area moments of interia, not mass moment of inertia. So you'll have to compute the mass moments of inertia.

       

Viewing 5 reply threads
  • The topic ‘Read Ixx, Iyy and the Centroid of selected face using 19.2 scripting’ is closed to new replies.
[bingo_chatbox]