how to assign value to vector array


#1

Hi,

How a value can be dynamically assigned to an element in a vector array?

The following loop is supposed to declare a vector array for each selected mesh, and assign each element with the translation value of each vertex within said mesh. But this loop for some reason assigns every value to the first element in the array.

string $meshes[] = ls -sl ;

for($i=0;$i<size($meshes);$i++)
{

int $vertCount[] = `polyEvaluate -v $meshes[$i]` ;
eval( "vector $" + $meshes[$i] + "Vct[] ;" ) ;

for($j=0;$j&lt;$vertCount[0];$j++)
{
	float $vertCord[] = `pointPosition -w ($meshes[$i] + ".vtx[" + $j + "]")` ;
	evalEcho( "vector $" + $meshes[$i] + "Vct[" + $j + "] = {&lt;&lt;" + $vertCord[0] + ", " + $vertCord[1] + ", " + $vertCord[2] + "&gt;&gt;} ;" ) ;
}

};

thanks in advance
:slight_smile:


#2

deleted…


#3

cool, the script seems to work now. i just combined the two commands in the nested loop into one. i cant believe i didn’t think of this earlier.

thanks anyways :slight_smile:

string $mesh[] = ls -sl ;

for($i=0;$i<size($mesh);$i++)
{

int $nvert[] = polyEvaluate -v $mesh[$i] ;
evalEcho(“vector $” + $mesh[$i] + “VCT[] ;” ) ;

for($j=0;$j<$nvert[0];$j++)
{
evalEcho( “$” + $mesh[$i] + “VCT[” + $j + "] = pointPosition -w " + ($mesh[$i] + ".vtx[" + $i + "]") + " ; " ) ;
}

}


#4

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.