Extract Young Modulus for each body

Options
Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 813
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
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: 813
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓
    Options

    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