While using TCL commands, how can I get the minimum (maximum) ID of selected entities (elements)

Ulrich W.
Ulrich W. Altair Community Member
edited December 2021 in Community Q&A

Hello, first please excuse if I post a question already answered earlier.

While programming a subroutine in TCL for automisation purpose, I need to get the minimum ID of elements (displayed, selected, or grouped) stored in a variable.

In further steps all attached elements to this element shall be moved to a new component in Hypermesh.

 

If any one could help and provide a solution I would be very glad.

Thank you in advance.

Ulrich

Answers

  • Ben Buchanan
    Ben Buchanan
    Altair Employee
    edited December 2021

    I think I would just do an lsort then get the first one in the list.

  • Hypermesh User
    Hypermesh User Altair Community Member
    edited December 2021

    Hi Ulrich,

     

    Please use the below code for your problem.

     

    eval *createmark elements 1 "displayed"
    set Maxeleid [hm_entitymaxid elements 1]

    eval *createmark elements 1 $Maxeleid
    *findmark elements 1 257 1 elements 0 2
    set adjele [hm_getmark elements 2]

    set countlst [llength $adjele]

    for {set i 0} {$i < $countlst} {incr i} {

    lappend Maxeleid [lindex $adjele $i]

    }

    *collectorcreateonly components "New_Collector" "" 11

    hm_createmark elems 1 $Maxeleid
    *movemark elements 1 "New_Collector"

     

    Please reply if you face any issues.

     

    Regards,

     

    Manoj M

  • Ben Buchanan
    Ben Buchanan
    Altair Employee
    edited December 2021

    Hi Ulrich,

     

    Please use the below code for your problem.

     

    eval *createmark elements 1 "displayed"
    set Maxeleid [hm_entitymaxid elements 1]

    eval *createmark elements 1 $Maxeleid
    *findmark elements 1 257 1 elements 0 2
    set adjele [hm_getmark elements 2]

    set countlst [llength $adjele]

    for {set i 0} {$i < $countlst} {incr i} {

    lappend Maxeleid [lindex $adjele $i]

    }

    *collectorcreateonly components "New_Collector" "" 11

    hm_createmark elems 1 $Maxeleid
    *movemark elements 1 "New_Collector"

     

    Please reply if you face any issues.

     

    Regards,

     

    Manoj M

    Nice Manoj.  I didn't know about the hm_entitymaxid command. Looks like it is also not documented.

    Looks like there is an hm_entityminid command also.

  • Hypermesh User
    Hypermesh User Altair Community Member
    edited December 2021

    Nice Manoj.  I didn't know about the hm_entitymaxid command. Looks like it is also not documented.

    Looks like there is an hm_entityminid command also.

    Dear Ben,

     

    I am glad that you have learned new command from me.

     

    For documentation please check below link.

     

    https://2020.help.altair.com/2020.1/hwdesktop/hwd/topics/reference/hm/hm_entitymaxid.htm?zoom_highlightsub=hm_entitymaxid

     

    Yes, As you said hm_entityminid is also there.. please explore..

     

    Regards,

     

    Manoj M.

  • Ben Buchanan
    Ben Buchanan
    Altair Employee
    edited December 2021

    Dear Ben,

     

    I am glad that you have learned new command from me.

     

    For documentation please check below link.

     

    https://2020.help.altair.com/2020.1/hwdesktop/hwd/topics/reference/hm/hm_entitymaxid.htm?zoom_highlightsub=hm_entitymaxid

     

    Yes, As you said hm_entityminid is also there.. please explore..

     

    Regards,

     

    Manoj M.

    Thanks.  I searched for entitymaxid and it didn't come up.  When you search for hm_entitymaxid it does come up.

  • Ulrich W.
    Ulrich W. Altair Community Member
    edited December 2021

    Hello Manoj

     

    thank you very much for your help.

    I´ll include the commands into my procedure

    I´m sure they will work, if I had described my problem correctly.

    Regards

    Ulrich 

  • Hypermesh User
    Hypermesh User Altair Community Member
    edited December 2021

    Hello Ulrich,

     

      Please mark as a correct answer if it works correctly ;-)

     

    Regards,

     

    Manoj M