Error: Can't read "vx1": no such variable
Hello all,
In a part of my script the vector coordinates are pulled for a later use. When I execute I have the following error message
---------------------------------------------------------------------------------------
Error:
can't read 'vx1': no such variable
while executing '*createvector 1 $vx1 $vy1 $vz1'
---------------------------------------------------------------------------------------
Code:
*vectorcreate_twonode $x $y
set vectorList [ hm_getmark vectors 1 ];
foreach vct $vectorList {
set vx1 [ hm_getentityvalue vectors $vct 'xcomp' 0 ]
set vy1 [ hm_getentityvalue vectors $vct 'ycomp' 0 ]
set vz1 [ hm_getentityvalue vectors $vct 'zcomp' 0 ]
return '{ $vx1 } { $vy1 } { $vz1 }'
}
*createmark nodes 1 $x
*duplicatemark nodes 1 25
set r [hm_entitymaxid nodes 1]
*createvector 1 $vx1 $vy1 $vz1
*translatemark nodes 1 1 10
-------------------------------------------------------------------------------------------------------------
Would be great if someone could tell how to reference the coordinates vx1, vy1 and vz1 in the other parts of the code.
Thanks in advance
Answers
-
You have a list of vectors but you want to translate it into one direction. The problem is that the variables are only valid within the for loop...
try this
set vector [*vectorcreate_twonode 1 2] set vx1 [ hm_getentityvalue vectors $vector 'xcomp' 0 ] set vy1 [ hm_getentityvalue vectors $vector 'ycomp' 0 ] set vz1 [ hm_getentityvalue vectors $vector 'zcomp' 0 ] *createmark nodes 1 1 *duplicatemark nodes 1 25 set r [hm_entitymaxid nodes 1] *createvector 1 $vx1 $vy1 $vz1 *translatemark nodes 1 1 10
I changed the $x and $y that it works for me... also the createmark command after that...
Hope this helps
0 -
Hi Merula, thank you so much for the new code and it works perfectly.
0