rafoarc
06-05-2008, 12:50 AM
Hello... I am working on the following script:
//part_01
int $xmax = 20;
int $ymax = 20;
//create the lattice of cells
for($x=0; $x<$xmax; $x++){
for($y=0; $y<$ymax; $y++){
polyPlane -ax 0 0 1 -w 1 -h 1 -sx 1 -sy 1 -name ("MyPlane" + $x + "x" +$y);
move $x $y 0;
}
}
//scale some of them randomly
for($x=0; $x<$xmax; $x++){
for($y=0; $y<$ymax; $y++){
$name = ("MyPlane"+$x+"x"+$y);
select -cl ;
select -r $name ;
if(rand(2) >1){
scale 0 0 0;
}
}
}
//part_02
//create a matrix that will contain the state of each cell
string $createMatrix = "matrix $cell_state[" + $ymax + "][" + $xmax + "]";
eval ($createMatrix);
//part_03
//get the state of each cell and add it to the matrix
for($x=0; $x<$xmax; $x++){
for($y=0; $y<$ymax; $y++){
//string $createMatrix = "matrix $cell_state[" + $ymax + "][" + $xmax + "]";
//eval ($createMatrix);
string $attribholder = "getAttr \"" + $name + ".scaleX\"";
$cell_state [$y][$x] = `eval ($attribholder)`;
}
}
When I try to run the whole script, I am getting the error: "$cell_state" is an undeclared variable. // However, when I run the three parts (part_1, part_2, part_3) seperately it is working fine! Any idea about what I am doing wrong? I tried to make $cell_state global with no luck and I tried to place the declaration of the matrix inside the for loop, no luck either....
Thanks!
//part_01
int $xmax = 20;
int $ymax = 20;
//create the lattice of cells
for($x=0; $x<$xmax; $x++){
for($y=0; $y<$ymax; $y++){
polyPlane -ax 0 0 1 -w 1 -h 1 -sx 1 -sy 1 -name ("MyPlane" + $x + "x" +$y);
move $x $y 0;
}
}
//scale some of them randomly
for($x=0; $x<$xmax; $x++){
for($y=0; $y<$ymax; $y++){
$name = ("MyPlane"+$x+"x"+$y);
select -cl ;
select -r $name ;
if(rand(2) >1){
scale 0 0 0;
}
}
}
//part_02
//create a matrix that will contain the state of each cell
string $createMatrix = "matrix $cell_state[" + $ymax + "][" + $xmax + "]";
eval ($createMatrix);
//part_03
//get the state of each cell and add it to the matrix
for($x=0; $x<$xmax; $x++){
for($y=0; $y<$ymax; $y++){
//string $createMatrix = "matrix $cell_state[" + $ymax + "][" + $xmax + "]";
//eval ($createMatrix);
string $attribholder = "getAttr \"" + $name + ".scaleX\"";
$cell_state [$y][$x] = `eval ($attribholder)`;
}
}
When I try to run the whole script, I am getting the error: "$cell_state" is an undeclared variable. // However, when I run the three parts (part_1, part_2, part_3) seperately it is working fine! Any idea about what I am doing wrong? I tried to make $cell_state global with no luck and I tried to place the declaration of the matrix inside the for loop, no luck either....
Thanks!
