Can someone help me translate this apdl code to pymapdl. I tried multiple things but it didnt work

component = 'CONTACT'

cmsel,,component !select Contact Faces acc. component
esln !select related Elements

ESEL,R,ENAME,,174 !Reselect all Contact Elements in Set

*GET,nelem,ELEM,,COUNT !count number of selected nodes on Faces

en=0 !initialize Elem Number to 0


*do,i,1,nelem !loop over nodes
en = ELNEXT(en) !next higher node number to nn
elem_data(i,1) = en !save node number to array
*GET, elem_data(i,2), ELEM,en,AREA



  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 158
    100 Comments 25 Likes 5 Answers First Anniversary

    Have you tried just calling this text as APDL input instead of converting it?
    I would also suggest using PyDPF to extract the element area via this operator. You can get a skin mesh and get the areas of that skin in python

    op = # operator instantiation
    op.inputs.mesh_scoping.connect(my_mesh_scoping)# optional
    my_mesh = op.outputs.mesh()
    my_nodes_mesh_scoping = op.outputs.nodes_mesh_scoping()
    my_map_new_elements_to_old = op.outputs.map_new_elements_to_old()
    my_property_field_new_elements_to_old = op.outputs.property_field_new_elements_to_old()

  • kanchan_cadfem
    kanchan_cadfem Member Posts: 15
    10 Comments 5 Likes First Answer Name Dropper

    @Shailesh Kumar : there are some limitations regarding the so called Process Controls

    you can follow this link for explanation.

    for conversion of your APDL code please follow something similar to this

    although you can do the above the recommended way is to use the pythonic way to convert your logic in python instead of APDL