collector name based on node id

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Hello,

 

      i'm trying to get collector name based on node id with the following script.

 

 set node(id) '
301388
210613
254295
151336
'      
foreach index [array names node] {
   puts '$node($index)'
   *createmark nodes 1 $node($index)  
   *findmark nodes 1 1 1 elems 0 2
   set elems [hm_getmark elems 2]
   foreach elemid $elems {puts [hm_getentityvalue elems $elemid collector.name 1 -byid]}
}

issue: script outs collector name corresponding to last node (151336) only please help me.

 

Answers

  • llyle_20499
    llyle_20499 New Altair Community Member
    edited November 2018

    Hi,

     

    Your first foreach is wrong, considering you're only interested in node(id) you can give it directly. 

     

    foreach nodeID $node(id) {
       puts $nodeID--nodeID
       *createmark nodes 1 $nodeID
       *findmark nodes 1 1 1 elems 0 2
       set elems [hm_getmark elems 2]
       puts $elems--elems;
      foreach elemid $elems {puts [hm_getentityvalue elems $elemid collector.name 1 -byid]}
    }

  • sandeepballiwar
    sandeepballiwar New Altair Community Member
    edited November 2018

    instead of second for loop, you can use the below commands

     

           *createmark elems 1 'by node' $node;

           if {[hm_marklength elems 1]} {

                 set lst_Comps [eval hm_parentcomplist id [hm_getmark elems 1]];

            }
     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited November 2018

    Hello Mr. Livil, Mr. Sandeep,

     

               Thank you 'it's working'.

    Regards,

    Anil.