Select elements from a set of nodes

vipin_22401
vipin_22401 Altair Community Member
edited October 2020 in Community Q&A

Hi all,

 

Is there any direct api to select elements from a set of nodes?( For example in the image i need the highlighted elements, dont need the adjacent elements to be selected.)

I tried *findmark and *createmark which are selecting the nearby elements too.

 

 

image.png.3c982e0171fe1c3a97b3ec6b7075d8a0.png

Answers

  • tinh
    tinh Altair Community Member
    edited October 2018

    Hi Vipin

    You can ignore adjacent elems

    *createmark nodes 1 {*}$NodeList

    *createmark elems 1 'by node' {*}[hm_getmark nodes 1]

    *createmark elems 1 reverse

    *appendmark elems 1 'by adjacent'

    *createmark elems 1 reverse

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited October 2018

    Another solution you can try is the following:

     hm_createmark nodes 1 'by id only' $NodeList; hm_createmark nodes 1 advanced reverse; hm_createmark elems 1 'by nodes' [hm_getmark nodes 1]; hm_getmark elems 1;

     

  • vipin_22401
    vipin_22401 Altair Community Member
    edited October 2018

    Nice trick @tinh, @akitoguc :D/emoticons/default_biggrin.png' srcset='/emoticons/biggrin@2x.png 2x' title=':D' width='20' />

    Works for me!

     

  • Roshan Shiveshwar
    Roshan Shiveshwar Altair Community Member
    edited October 2018

    Just another way to handle this....

     

    *createmarkpanel nodes 1 'Select nodes to which the attached elements have to be determined'
    eval '*createmark elems 1 \'by nodes\' [hm_getmark nodes 1]'
    eval '*createmark nodes 2 \'by elems\' [hm_getmark elems 1]'
    *marknotintersection nodes 1 nodes 2
    eval '*createmark elems 2 \'by nodes\' [hm_getmark nodes 1]'
    *markdifference elems 1 elems 2
    set attached_elem_list [hm_getmark elems 1]

  • tinh
    tinh Altair Community Member
    edited October 2018

    Oh, many ways...

    @vipin should test which one is the fastest

    Using cmd

    time {script}

    To measure time to finish a script

  • vipin_22401
    vipin_22401 Altair Community Member
    edited October 2018

    @tinh

    Tested all methods, last one runs faster on bigger assemblies (saves around 5 sec ;)/emoticons/default_wink.png' srcset='/emoticons/wink@2x.png 2x' title=';)' width='20' /> ).

    Thanks again all!