Class 5: Sample MEL scripts, part 2

Dynamics

particlesOnVertices

chain

Utils

toggleVisibility

curveFromRaw

UI

lightInten

exportSeriesWin (and chainUI )

Interact with Maya from a web browser - obsolete but COOL!!!!

Expressions

These are just 'regular' MEL (with vars, flow control, procs..) typed inside the expression editor window, with pre-defined vars such as time and frame. An expression can also be created using the 'expression' (or 'dynExpression') MEL commmand.


Ball.translateX = Cube.translateX + 5;
Cube.translateZ = time;
Ball.scaleX = 1 + time;
Cone.scaleY = (0.5 + sin(time)*5);
if (time<3.0)
{
Ball.scaleY = time;
}

What does the following expression (expressed as a MEL statement) do?

expression -e -s "catch(delete(\"nurbs*\"));\nsphere -r 0.2;\nfloat $x = rand(4), $y=rand(4), $z=rand(4);\nmove $x $y $z;"  -o "" -ae 1 -uc all  expression1;

Here is another example. As you can see, 'xform' (and other cmds) will also work inside an expression :)

file -f -new;

sphere;

sphere;
move 1 2 3;

playbackOptions -e -min 0;
playbackOptions -e -max 100;

expression -s "string $cv = \"nurbsSphere1.cv[\" + frame + \"][0]\";\n\nfloat $cvPosition[] = `xform -q -ws -t $cv`;\n\n\n$cv = \"nurbsSphere2.cv[\" + frame + \"][0]\";\n\nxform -ws -t  $cvPosition[0] $cvPosition[1] $cvPosition[2]  $cv;"  -o nurbsSphere2 -ae 1 -uc all ;


play -st 1;