PDA

View Full Version : Need help - working with vectors.

 DarcAngelo09-28-2009, 11:55 PMHi, I'm trying to write a script at the moment that uses a lot of vectors and I've run into a scripting issue. I need to work with vector arrays but I can't seem to access array elements properly. For example: This works: vector \$testb = <<1,1,1>>; print (\$testb.x); //Returns: 1 So does this: vector \$test[3] = {<<1,1,1>>,<<2,2,2>>,<<3,3,3>>}; print (\$test[2]); //Returns: 3 3 3 However, this doesn't: vector \$test[3] = {<<1,1,1>>,<<2,2,2>>,<<3,3,3>>}; print (\$test[2].x); // Error: print (\$test[2].x); // // Error: Line 2.17: Syntax error // So my question is - does anyone know how to access vector array elements? How about assigning new values to an element (e.g.: \$test[2].x = 4)? Any help would be greatly appreciated. :)
theflash
09-29-2009, 02:53 AM
However, this doesn't:
vector \$test[3] = {<<1,1,1>>,<<2,2,2>>,<<3,3,3>>};
print (\$test[2].x);
// Error: print (\$test[2].x); //
// Error: Line 2.17: Syntax error //

So my question is - does anyone know how to access vector array elements? How about assigning new values to an element (e.g.: \$test[2].x = 4)?

Any help would be greatly appreciated. :)

vector \$temp = \$test[2];
print \$temp.x;

?

Serashi
09-29-2009, 03:00 AM
Hey,

I know of one way to do it, might be more.

But you can create a temp vector variable and place the vector at array X into that.
Might not be best explanation, but here is a code snippet:
--------------------------------
vector \$VectorData[] = {<<0,1,2>>, <<3,4,5>>};

vector \$tempData = \$VectorData[0];
print (\$tempData.x);

---------------------------------

not sure how to assign new values to an element though.

DarcAngelo
09-29-2009, 05:38 AM
Thanks for the idea guys. Yeah looks like vectors are really strangely handled in MEL. :(

I'm finding a lot of limitations in MEL these days that makes me think I should learn how to program in the API.

bazuka
09-29-2009, 08:17 AM
why dont u try python? ;)

CGTalk Moderation
09-29-2009, 08:17 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.