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

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 712
First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
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: 712
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    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: 177
    First Answer First Comment 5 Likes First Anniversary

    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.