Mel - Maya Embedded Language

array

Arrays, though they may appear daunting at first, are not all that hard to use. Once you get the basic idea of how arrays work, they are actually pretty easy to use.

An array is simply a series of variables. This is actually a pretty nice thing. Think about it, we can use an arrays to store mulitple values under one variable name.This comes in handy when trying to store multiple object names, etc...

Lets see the format of a simple array:

string $myArray[ ] = {"one","two","three","four"};
int $myArray2[ ] = {1,2,3,4}
You can gather the length of your array using the size command.
string $myArray[ ] = {"polyCube","polyShpere","polyPlane","polyCylinder"};
int $myArraySize = size($myArray);
print $myArraySize;
An easy way to add objects into an array is by using the ls command. To set an array to this command write it as such:
string $myNewArray[ ] = `ls -sl`;
Notice when I used ls that I put backquote marks around it ( ` ) This is located above the tab key. Using this this returns a result