How can I extract basic geometry information for a body in SpaceClaim?

Nikos Kallitsis
Nikos Kallitsis Member, Employee Posts: 38
10 Comments 5 Likes First Anniversary Ansys Employee
✭✭✭✭

I have some bodies designed in SpaceClaim and want to extract some basic geometric information like body center and bounding box.

Best Answer

  • Nikos Kallitsis
    Nikos Kallitsis Member, Employee Posts: 38
    10 Comments 5 Likes First Anniversary Ansys Employee
    ✭✭✭✭
    Answer ✓

    You can extract the requested information by using SpaceClaim scripting. Here is a sample script:

    #Body Center
    bodySelection = BodySelection.Create(GetRootPart().Bodies[0])
    designBodySelection = body.Bodies[0]
    bodyMassProp = designBodySelection.MassProperties
    bodyCenter = bodyMassProp.PrincipleAxes.Origin
    bodyCenterX = bodyCenter.X
    bodyCenterY = bodyCenter.Y
    bodyCenterZ = bodyCenter.Z
    
    #Body Bounding Box
    bodyBox = designBodySelection.Shape.GetBoundingBox(Matrix.Identity)
    bodyCenter2 = bodyBox.Center #Should be equal to bodyCenter from above
    bodyCorners = bodyBox.Corners
    bodyCornerPoint = bodyCorners[0]
    bodyCornerPointX = bodyCornerPoint.X