how to get elements based on element name IDs using ansys mechanical scripting?

amusthaf
amusthaf Member Posts: 16
First Anniversary Name Dropper First Comment
**

for example, if I want to get all the elements of CONTAC174 of ename, how do I get it?

Comments

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 357
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭

    There are lots of ways to do this but the easiest way will depend on your use case. Can you give more context? For example, is this for post processing after the solution file is available? What are you wanting to do with the Ids?

    Also, getting all contact elements is different from getting other types as contact elements do not “exist” in Mechanical. They are created at runtime while other elements for bodies exist in Mechanical directly and Ids are available assuming the model is meshed.

  • amusthaf
    amusthaf Member Posts: 16
    First Anniversary Name Dropper First Comment
    **
    edited August 2023

    Hello Mike,

    Yes, Mike, I would be doing it after solving the model. I am trying to do something equivalent to the APDL commands:
    esel,,ename,,174
    esel,a,ename,,170
    nsle
    cm,facenodes,node
    esel,,ename,,175
    nsle
    cm,edgenodes,node

    I wanted to select all the elements that corresponds to contact regions in the model and create named selection as per its geometrical selection, like if surfaces have been selected to give contact between two bodies, its corresponding elements to be grouped in "faceelements," likewise if edges being selected, it is to be grouped in "edgeelements."

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

    Hi @amusthaf , it will not be possible to create named selections of contact elements in Mechanical,as these elements are not shown in the Mechanical UI. You could use APDL command snippets to create the named selection, but the named selection will not show up in the Mechanical UI. With the Mechanical automation API, you can create named selections, but only the ones that can be created through the Mechanical UI too. There's a post about creating worksheet named selections here: https://discuss.ansys.com/discussion/comment/639#Comment_639. You could create a named selection for the geometrical faces though (the ones meshed with SOLID187 elements in your example, on top of which the contact/target elements get created).
    Depending on what you'd like to do exactly, you can also use Solver Data API to get contact-specific data (see this page of the help: https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v232/en/act_script/mech_apis_SolverData_Object_Spec_Data.html)