Can I change material properties in SpaceClaim through Scripting?

Options
Nikos Kallitsis
Nikos Kallitsis Member, Employee Posts: 24
First Anniversary First Comment Ansys Employee Name Dropper

How can I access and change the properties of a Material assigned to a body in the Tree?

Best Answer

  • Nikos Kallitsis
    Nikos Kallitsis Member, Employee Posts: 24
    First Anniversary First Comment Ansys Employee Name Dropper
    Answer ✓
    Options

    To access the body's material:

    b = GetRootPart().Bodies[0]
    mat = b.Material

    Assume we want to change/set the Elastic Modulus to a value of 15. The user should first set the property and assign it to the Material:

    matId = SpaceClaim.Api.V20.MaterialPropertyId
    prop = SpaceClaim.Api.V20.MaterialProperty(matId.ElasticModulus,"Elastic Modulus",15,None)
    mat.SetProperty(prop)

    Another option would be to access the material object directly and setting the property from there. Post on how to access the material object here. After having defined the local_mat object, the above snippet's last line should be changed to:

    local_mat.SetProperty(prop)