The surface to which an element belongs

Akane Ito
Akane Ito Member Posts: 30
10 Comments Name Dropper
**

Is it possible to obtain the faceId to which a certain element belongs?

Answers

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

    Please clarify your question: what tool are you using ? Mechanical, MAPDL, PyMechanical, PyMAPDL?

  • Akane Ito
    Akane Ito Member Posts: 30
    10 Comments Name Dropper
    **

    It's Mechanical.

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

    This should help: https://discuss.ansys.com/discussion/comment/3689#Comment_3689?utm_source=community-search&utm_medium=organic-search&utm_term=MeshData You would have to adapt it to get the face in geobody, instead of the entire body, but the principle stays the same.

  • Akane Ito
    Akane Ito Member Posts: 30
    10 Comments Name Dropper
    **

    Dear Pernelle Marone-Hitz
    I tried it using the method I was taught, but it didn't work out. If possible, please provide specific instructions.

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

    The only thing to add from the previous script is to loop on the faces of the geobody.

    element_id  = 25
    mesh_data = ExtAPI.DataModel.Project.Model.Analyses[0].MeshData
    bodies = ExtAPI.DataModel.Project.Model.Geometry.GetChildren(DataModelObjectCategory.Body, True)
    for body in bodies:
        geobody = body.GetGeoBody()
        for face in geobody.Faces:
            mesh_for_face = mesh_data.MeshRegionById(face.Id)
            if element_id in mesh_for_face.ElementIds:
                print('Element ' + str(element_id) + ' is in face : ' + str(face.Id))
    
  • Akane Ito
    Akane Ito Member Posts: 30
    10 Comments Name Dropper
    **

    Dear Pernelle Marone-Hitz
    Thank you for teaching me. It was very helpful!