PDA

View Full Version : how could i return the size of a matrix?


MegaManZZ
02-06-2008, 09:45 PM
is there a way to return the size of a matrix?

such as
matrix $aMatrix[2][3] = << 1,2,3; 4,5,6>>;
int $size = size($aMatrix);

??????????/

Omita
02-08-2008, 09:42 PM
See Maya Docs for help: file:///C:/Program Files/Alias/Maya8.0/docs/Maya8.0/en_US/General/Can_I_specify_a_dynamic_matrix.html

r4inm4ker
02-09-2008, 02:19 AM
as far as i know, you couldn't create a dynamic matrix, so by the time you declare the matrix, you already know the size :D .
I don't recommend using matrix though, it can't be erased from memory unless you close Maya. so if you insist to use MEL, then use multiple arrays with some indexing.

meljunky
02-14-2008, 03:18 AM
On the same lines as r4inm4ker said...

I have used a string array to store XYZ as a string array before.

For example:
string $pose[] = {"x1 y1 z1", "x2 y2 z2", "x3 y3 z3"};

Each float number seperated by a space, then when I wanted access, I simply tokenize the string and type cast it back to a float value. The benefit is that the index still mean something rather then existing in multiples of 3. (x1, y1,z1, x2, y2, z2, x3, y3, z3... size of 9)

You sort of can create a dynamic matrix. I say sort of because it has no pratical use. In the script editor run the following commands:

int $a = 2;
int $b = 3;
eval("matrix $testA[" + $a + "][" + $b +"]");

Then execute the command:

print $testA;

The results are:

<< 0, 0, 0;
0, 0, 0>>

Viola! A Dynamic Matrix! This is where it has no pratical use. You cannot execute all 4 lines as one block of code, nor can be embedded in a script file. Only works in the method I listed and cannot be redeclared with different sizes. Only pratical use I see for it, is to win a bet.

Hope the string array info helps, not the dynamic matrix thing,
-Brian
www.meljunky.com (http://www.meljunky.com)

strarup
03-05-2008, 08:54 AM
Hi,

don't know if this is useful... but you can e.g. look at this script example from this thread...
File i/o question... -->
http://forums.cgsociety.org/showthread.php?t=522598

it isn't a matrix however an example of how to use multible string arrays with the help of tokenize... :)

kind regards

Strarup

MegaManZZ
03-05-2008, 02:24 PM
very cool read! thank you

CGTalk Moderation
03-05-2008, 02:24 PM
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.