invalid attribute index

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  09 September 2005
invalid attribute index

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
__________________
self-plug! - winged dude - post apocaplytic -
 
  09 September 2005
Thumbs up

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

should be this:
$pont = pointPosition ("pPlane1.vtx [" + $numvert + "]");
 
  09 September 2005
Thumbs up

int $x = 3 ;
int $y = 5 ;

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

//$m is your variable-sized matrix


Cheers
 
  09 September 2005
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?
__________________
self-plug! - winged dude - post apocaplytic -
 
  09 September 2005
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:39 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.