Extract Young Modulus for each body

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
100 Answers 500 Comments 250 Likes First Anniversary
✭✭✭✭
edited June 2023 in Structures

How can I extract Young Modulus value for each body in Mechanical, through scripting?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭
    Answer ✓

    The following function can be used:

    def ExtractMaterialYoungModulus():
        '''
        Extract Young Modulus value for each body in model
        '''
        listExportMaterialYoungModulusProperties = []
        import materials
        for part in ExtAPI.DataModel.Project.Model.Geometry.Children:
            for body in part.Children:
                if body.Suppressed is False:
                    geoBody = body.GetGeoBody()
                    bodyName = body.Name
                    bodyMaterial = body.Material
                    geoBodyMaterial = geoBody.Material
                    try:
                        bodyElasticityValues = materials.GetMaterialPropertyByName(
                            geoBodyMaterial, "Elasticity")
                        bodyYoungModulus = bodyElasticityValues[
                            "Young's Modulus"]
                        bodyYoungModulusUnit = bodyYoungModulus[0]
                        bodyYoungModulusValue = bodyYoungModulus[1]
                    except:
                        bodyYoungModulusUnit = "No aplica"
                        bodyYoungModulusValue = "No aplica"
                    listExportMaterialYoungModulusProperties.append([
                        str(bodyName),
                        str(bodyMaterial),
                        str(bodyYoungModulusUnit),
                        str(bodyYoungModulusValue)
                    ])
        return listExportMaterialYoungModulusProperties