🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

remove node from the nodelist after renumbering through script

Hi,

Using script, i am trying to renumber a set of selected nodes using shortest distance from a point.

i am using following script to do that. In which I am trying to renumber closest node one by one and once renumbering is done, I want to remove that node from the selected node list. 

But it is not working as intended. Can some one help me what is wrong in the code? or is there any alternate method to do that through script?

*createlistpanel nodes 1 
set nodelist [hm_getlist nodes 1] 
set nodelist_num [llength $nodelist] 
puts $nodelist_num 
for {set i 1} {$i<=$nodelist_num} {incr i} {
*createmark nodes 1 $nodelist 
set closenode [hm_measureshortestdistance2 120 120 550 nodes 1 0 0] 
set cnode [lindex $closenode 4] 
*createmark nodes 1 $cnode 
*renumbersolverid nodes 1 [expr $i+10] 1 0 0 0 0 0 
regsub $cnode $nodelist '' nodelist 
set *nodelist_num [llength $nodelist] 
puts $nodelist_num 
*clearmark nodes 1 }

 

 

Find more posts tagged with

Sort by:
1 - 2 of 21

    Had a quick look and there is a pre-existing script in the library that seems to do something very similar? 

    Renumber Script

    Does this do what you need?

    tinhUser: "tinh"
    Altair Community Member
    Updated by tinh

    Hi

    try again, modify this command:

          *createmark nodes 1 $nodelist 

    to:

          *createmark nodes 1 {*}$nodelist 

     

     

    This command is very dangerous (never use it to modify lists):

          regsub $cnode $nodelist '' nodelist 

    Should be:

          set nodelist [lremove $nodelist $cnode]

     

    And change this command:

          set *nodelist_num [llength $nodelist] 

    to:

          set nodelist_num [llength $nodelist]