How to retrieve the material name of an element in mesh ?

Options
mahmane
mahmane Member Posts: 6
First Comment

I want to get the material name for each element so ican get it's properties in engineering data. i am using dpf but it only gave me the matid and i don't know how to link it to the name of the material. Thank you in advance. @AKD-Scripting-Team

Answers

  • Rajesh Meena
    Rajesh Meena Moderator, Employee Posts: 77
    First Anniversary Solution Developer Community of Practice Member Ansys Employee 5 Likes
    Options

    @mahmane How about going to from mesh to body and then from body to material. This is possible in the mechanical itself.

    Are you trying to get mesh from rst?

  • mahmane
    mahmane Member Posts: 6
    First Comment
    Options

    Not necessary from rst, i am using DPF to get the mesh and a Field with a mat_id for each element, but to extract the material propreties i use the libraries "materials" and "EngineeringData" with the name of the material, My problem here is that i can't have the material name by his mat_id. Otherwise i need to try another way as you suggested, do you have a script for that Please?

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 215
    First Answer First Comment 5 Likes First Anniversary
    Options
    element = ExtAPI.DataModel.MeshDataByName('Global').Elements[0]
    body = element.GetBody()
    material = body.Material
    print(material.DisplayName)
    
  • dafedin
    dafedin Member Posts: 21
    First Anniversary First Comment Name Dropper
    Options

    hello Landon,

    Very useful script. I wonder is there a way to get material ID? I faced trouble getting it using the function GetPropertyField("mat") which doesn't exist in the 21R2 release.

    Thanks

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 215
    First Answer First Comment 5 Likes First Anniversary
    edited September 2023
    Options

    material.ID

  • dafedin
    dafedin Member Posts: 21
    First Anniversary First Comment Name Dropper
    Options

    Hello Landon,

    Maybe I didn't come right... I mean the unique material identifier (matid) which is assigned to each material in ds.dat, for example:

    !*********** Model Summary ********************
    !Part 12,     Structural Steel,   matid,    1
    !Part 13,     Structural Steel,   matid,    2
    !Part 14,     Structural Steel,   matid,    3
    !Part 133,    Structural Steel,   matid,    4
    !Part 134,    Structural Steel,   matid,    5
    !Part 135,    Structural Steel,   matid,    6
    !*********************** End Model Summary *****************
    

    material.ID doesn't return matid.

    Thanks

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 215
    First Answer First Comment 5 Likes First Anniversary
    Options

    The APDL matids are dynamically assigned when the ds.dat is generated (when you click solve) and can vary for each analysis. I am not sure if they are stored anywhere under ExtAPI.DataModel.

    You may find this post helpful:
    https://discuss.ansys.com/discussion/comment/1428#Comment_1428

    Otherwise, I would suggest creating a new Question on this topic.

    @AKD-Scripting-Team, is there an existing post on how to obtain APDL matids in Mechanical?