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 }
Answers
-
Had a quick look and there is a pre-existing script in the library that seems to do something very similar?
Does this do what you need?
0 -
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]
0