How to access Center of Mass in SpaceClaim/Discovery?

Andrew Stankovich
Andrew Stankovich Member, Employee Posts: 10
Ansys Employee First Comment Photogenic
edited June 2023 in 3D Design

How can you access the center of mass of body inside Discovery or SpaceClaim?

Answers

  • Andrew Stankovich
    Andrew Stankovich Member, Employee Posts: 10
    Ansys Employee First Comment Photogenic

    The center of mass is stored in the MassProperties of a body and can be accessed via the PricipleAxes.Origin.

    Also, there is a MeasureHelper function to directly get the center of mass from a selection. This can be helpful if you need the combined center of mass of multiple bodies.

    Code Example:

    bodies= GetRootPart().GetAllBodies()
    for body in bodies:
      print body.MassProperties.PrincipleAxes.Origin
      print MeasureHelper.GetCenterOfMass(Selection.Create(body))