Examples: // helloGoal.mel // from Chapter 16, Example 1 of MEL Scripting for Maya Animators // by Mark R. Wilkins and Chris Kazmier // Copyright 2003, Morgan Kaufmann Publishers /*----------------------------------------------------------------------- A simple particle goal example that will make two different color particle systems rotate around each other with a 300 frame range animation. -----------------------------------------------------------------------*/ global proc helloGoal() { // Create particle systems particle -p 5 0 -5 -n partOne; particle -p -5 0 5 -n partTwo; // Set rendering type to "sphere" setAttr partOne.prt 4; setAttr partTwo.prt 4; // Set radius size addAttr -ln radius -dv 0.5 partOneShape; addAttr -ln radius -dv 0.5 partTwoShape; // Set the particle colors addAttr -ln colorGreen -dv 1 -at double partOneShape; addAttr -ln colorRed -dv 1 -at double partTwoShape; // Add goals to each set of particles. 1 to 2, 2 to 1. goal -g partTwo -w 0.2 partOne; goal -g partOne -w 0.2 partTwo; // Add velocity vectors to the particles in +Y and -Y. particle -e -at velocity -id 0 -vv 0 3 0 partOne; particle -e -at velocity -id 0 -vv 0 -3 0 partTwo; // Set the goal smoothness for each goal. setAttr partOneShape.goalSmoothness 4.0; setAttr partTwoShape.goalSmoothness 4.0; // Set the playback range to 1 - 300 playbackOptions -min 1 -max 300; } Simple UI Example: // hunt_for_blah.mel // from Chapter 13 of MEL Scripting for Maya Animators // by Mark R. Wilkins and Chris Kazmier // Copyright 2003, Morgan Kaufmann Publishers int $keepgoing = 1; while ($keepgoing) { promptDialog -message "type a string containing the word blah please!"; string $typedString = `promptDialog -q`; string $matches_blah = `match "blah" $typedString`; int $found_match = ! `strcmp "blah" $matches_blah`; // Remember, strcmp returns 0 if the strings are equal if ($found_match) { $keepgoing = 0; } } print "Found blah!\n"; Collisions: // Chapter17_1.mel // from Chapter 17, Example 1 of MEL Scripting for Maya Animators // by Mark R. Wilkins and Chris Kazmier // Copyright 2003, Morgan Kaufmann Publishers polyPlane -width 1 -height 1 -subdivisionsX 4 -subdivisionsY 4 -axis 0 1 0; rename pPlane1 Floor; setAttr Floor.scaleX 6; setAttr Floor.scaleY 6; setAttr Floor.scaleZ 6; string $eObject[] = `emitter -position 0 4 0 -type direction -name Emit -rate 30 -speed 1 -spread 0.2 -dx 0 -dy -1.0 -dz 0`; string $pObject[] = `particle`; connectDynamic -em $eObject[0] $pObject[0];j playbackOptions -min 1 -max 500; collision -resilience 1.0 -friction 0.0 Floor; connectDynamic -collisions Floor particle1; setAttr geoConnector1.resilience 0.0; setAttr geoConnector1.friction 0.2; xform -rotation -26 0 0 Floor; duplicate -name Floor1 Floor; xform -a -translation 0 -3 -3 Floor1; xform -a -rotation 26 0 0 Floor1; collision -resilience 0 -friction 0.2 Floor1; connectDynamic -collisions Floor1 particle1; gravity -magnitude 3 -attenuation 0.0; connectDynamic -fields gravityField1 particle1; setAttr particle1.particleRenderType 4; BuildBlock: global proc buildBlock(int $width, int $depth, float $startX, float $startZ) { int $i, $j, $height; for($i=0; $i<$width; $i++) { for($j=0; $j<$width; $j++) { polyCube; $height = rand(10); scale 0.9 $height 0.9; move ($i + $startX) ($height / 2.0) ($startZ + $j); }; }; }; BuildCity: global proc buildCity(int $blockWidth, int $blockDepth, int $blocksWide, int $blocksDeep) { int $i, $j, $height; polyPlane; scale ($blockWidth * $blocksWide) 1 ($blockDepth * $blocksDeep); for($i=0; $i<$blocksWide; $i++) { for($j=0; $j<$blocksDeep; $j++) { buildBlock($blockWidth, $blockDepth, ($i * $blockWidth), ($j * $blockDepth)); }; }; }; CameraShake: float $tx, $ty, $tz, $rx, $ry, $rz; int $t; camera; rename "myCamera"; for($t=0; $t<400; $t = $t + 5) { currentTime $t; // translation $tx = getAttr("camera2.translateX"); $ty = getAttr("camera2.translateY"); $tz = getAttr("camera2.translateZ"); $tx = $tx + rand(0.2); $ty = $ty + rand(0.2); $tz = $tz + rand(0.2); setAttr "myCamera.translateX" $tx; setAttr "myCamera.translateY" $ty; setAttr "myCamera.translateZ" $tz; // rotation $rx = getAttr("camera2.rotateX"); $ry = getAttr("camera2.rotateY"); $rz = getAttr("camera2.rotateZ"); $rx = $rx + rand(0.2); $ry = $ry + rand(0.2); $rz = $rz + rand(0.2); setAttr "myCamera.rotateX" $rx; setAttr "myCamera.rotateY" $ry; setAttr "myCamera.rotateZ" $rz; // key attributes setKeyframe "myCamera.tx"; setKeyframe "myCamera.ty"; setKeyframe "myCamera.tz"; setKeyframe "myCamera.rx"; setKeyframe "myCamera.ry"; setKeyframe "myCamera.rz"; }