PDA

View Full Version : invalid attribute index


Dyrn
09-20-2005, 02:13 PM
I'm fairly new to MEL scripting, but my grasp of programming principles is solid. I'm working on a script that should find the y-coordinate of each vertex of a plane, and save everything into a matrix for later use.

Now, I've already been burnt because I couldn't use a variable where I wanted to (initial matrix dimensions), and I really, REALLY hope that's not the case here. See Below.


&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

// step 1
//build a matrix to hold the Y values
//no variable-dimension matrices my ass
// take this, MEL
//**************************************
//**************************************

int $subz = getAttr ("polyPlane1.subdivisionsHeight") + 1 ;
int $subx = getAttr ("polyPlane1.subdivisionsWidth") + 1 ;

matrix $yval[200][200] ;

//**************************************
//**************************************

// step 2
// get the y values of each point of
// the plane and keep it in the matrix
//**************************************
//**************************************

int $x ;
int $z ;
int $numvert = 0 ;
vector $pont ;


for ($x = 0; $x <= $subx; $x++) {
for ($z = 0; $z <= $subz; $z++) {

$pont = pointPosition ("pPlane1.vtx [$numvert]");

$yval [$z][$x] = $pont ;

$numvert++ ;

}
}

print $yval ;
// Error: Invalid attribute index: pPlane1.vtx [$numvert] //

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


Is this a case of I have to use a number, not a variable, to specify the vertex for the pointPosition command? If not, could someone tell me what the crap I'm doing wrong? If so, does anyone have any suggestions as per workarounds?

Thanks all

harmless
09-20-2005, 03:28 PM
this:
$pont = pointPosition ("pPlane1.vtx [$numvert]");

should be this:
$pont = pointPosition ("pPlane1.vtx [" + $numvert + "]");

harmless
09-20-2005, 03:34 PM
int $x = 3 ;
int $y = 5 ;

string $trickMaya = ("matrix $m[" + $x + "][" + $y + "];") ;
eval $trickMaya ;

//$m is your variable-sized matrix


Cheers

Dyrn
09-21-2005, 05:28 AM
Thanks, eh.

I've realized, however, why there was no obvious way to make a variable-sized matrix. SO, here's my next question. Is there any way to wipe past matrices? As it stands, the variable-sized matrix works like a charm the first time, and then seizes up because it won't overwrite the past iteration of itself. Thoughts?

CGTalk Moderation
09-21-2005, 05:28 AM
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.