Error: Can't read "vx1": no such variable

Ushay
Ushay Altair Community Member
edited October 2020 in Community Q&A

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

 

Tagged:

Answers

  • Merula_20758
    Merula_20758 Altair Community Member
    edited October 2019

    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

  • Ushay
    Ushay Altair Community Member
    edited October 2019

    Hi Merula, thank you so much for the new code and it works perfectly. 

     

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.