I've played with Mel, (Maya embeded language), on and off over the years but, to be honest, I never dug deeply into it. I can't figure out why - would have made life so much easier. I'm thoroughly enjoying the process of learning Mel and python at the moment. It's so very addictive.... and helpful :)
Here is a few of the basics in mel...
Data types
Integers
int $areWholeNumbers = `##`
Floats
float $areFractions = `##`
Vectors
vector $areX,Y,ZPositions = <<X,Y,Z>>
Array
$##[starts at 0]
Conditional Statements for mel
<: - less then, >: - greater then, == - equal to: != - not equal to, >= - greater or equal to: <= - less or equal to ?: -if else && -logical and || -logical or +,- -plus,minus ^ -vector cross product / -divide * -multiply % -modulo ++, -- -increment,decrement by 1 ! -not
Loops/Iterantion in Mel
While-Loops
example;
int $x =0;
while ($x <10)
{
$x =$x+1;
print ($x + "\n");
print ($x + "\n");
}
For-Loops (loop start) (loop end) (increment)
example;
for ($t=0; $t<6; $t=$t+1)
{
joint -name ("naths_" + "_jnt");
}
For-In-Loops
example
select bob;
string $bobsInHere[] =`ls -sl`;
for ($allBobsAtributes in $bobsInHere)
{
string $bobsAtributes[] = `listAttr -write $allBobsAtributes`;
for ($bobsWritable in $bobsAtributes)
{
print ($bobsWritable + " is a writable attribute of bobs" +"\n");
}
}
Do-While Loop
int $t = 1;
do
{
$t += 3;
print ($t + "\n");
}
while ($t <= 10);
Do-While Loop
int $t = 1;
do
{
$t += 3;
print ($t + "\n");
}
while ($t <= 10);
Special Characters of note
\ =escape,
\n = newline,
/t = tab,
\r = carriage return
Procedures
An example is a global procedure. The procedure is called from memory with the bottom line and arguments are given for width, height, depth and name.
Example;
global proc nathansCubeIT (float $width, float $height, float $depth, string $name)
{
polyCube -width $width -height $height -depth $depth -name $name;
}
nathansCubeIT 5 6 4 nathCube;