Error when I try to import material more than oncce in Ansys mechanical.

Collins
Collins Member Posts: 24
10 Comments Name Dropper
**

I get the error message

Error HRESULT E_FAIL has been returned from a call to a COM component.

Anytime I import materials more than once using the code below

For 232:

materials = DataModel.Project.Model.Materials
materials.Import(material_file)

As discussed here: https://discuss.ansys.com/discussion/2363/import-materials-in-pymechanical

I am not sure if the import is expected to work only once in ansys mechanical.

Any help will be much appreciated.

Answers

  • Collins
    Collins Member Posts: 24
    10 Comments Name Dropper
    **

    Following up on this question

    I observed that each material has a Unique Material ID (matid) once you import an XML material file the matid is registered and can't be imported a second time.

    BUT!
    if you wander into the XML file and change a single character of the matid then you can import the same material XML file as many times as you want.

    Note: I used this to change material properties iteratively for sensitivity analysis.

    Cheers

    Also if anyone knows a better way to change material properties using Python script (not from workbench) kindly drop here