How can I get the moments of inertia on a body?

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 864
500 Comments Photogenic Name Dropper Solution Developer Community of Practice Member
✭✭✭✭
edited June 2023 in Structures

How can I get the moments of inertia on a body through scripting?

Tagged:

Best Answer

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 864
    500 Comments Photogenic Name Dropper Solution Developer Community of Practice Member
    ✭✭✭✭
    Answer ✓

    The following code can be used:

    def GetMoments_byCS(body,CS,unitID=None):
        if unitID == None:
            unitID = ExtAPI.DataModel.InternalObject["ds"].UnitSystemID
        cadUnits = ExtAPI.DataModel.Project.Model.Geometry.InternalObject.CADUnits
        sm = ExtAPI.SelectionManager
        smio = ExtAPI.SelectionManager.InternalObject
        selection = sm.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
        selection.Ids = [body.GetGeoBody().Id]
        sm.ClearSelection()
        sm.AddSelection(selection)
        MMI = ExtAPI.DataModel.Project.Model.InternalObject.getMassMomentofInertiaofOneSelectedBody(unitID,cadUnits, smio, 1, CS.ObjectId)
        return [MMI.Item(x+1) for x in range(6)]
    

Answers

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 290
    100 Comments 25 Answers 25 Likes Photogenic
    ✭✭✭✭

    Note that this solution relies on undocumented commands, which are outside of any Quality Assurance (QA) programs and may not be forward compatible. Use at your own risk.