MEL Scripting:

arrows.GIF

List of Mel commands:
Help->Maya Scripting Reference->MEL Command Reference

Open the Window->General Editors->Script Editor...
Paste your script in the lower MEL area
Use Command->Execute from the editor


// comments a line
always end a command line with a ;   semi colon



Select with a wild card
select -r "nurbsPlane\*";



select 10 nurbsplanes
int $i;
for ($i = 1; $i <= 10; $i++) {        // The variable $i is equal to between 1 and 10
select -tgl ("nurbsPlane"+$i);}


Randomize a poly sphere
Use Display->Heads Up Display->Poly Count to see how many vertices are on your sphere
int $i;
for ($i = 1; $i <= 381; $i++) {
select -r pSphere1.vtx[$i] ;
move -r (rand(-.1,.1)) (rand(-.1,.1)) (rand(-.1,.1)) ;}




Print a list from 1 to 10 with a period and line return
int $i;
for ($i = 1; $i <= 10; $i++) {
print($i+".\n");}



string $object = "cake";
setAttr ($object + ".tx") 2;       //Syntax to string words together for a  command


Select a bunch of texture maps, turn off Quadratic
string $sel[] = `ls -sl`;
for($i=0;$i<size($sel);$i++) {
print ($sel[$i]+"\n");
setAttr ($sel[$i]+".filterType") 0;
};

Select a sphere with animation, copy it 10 times, each copy moves 3 units in x
int $i;
for ($i = 1; $i <= 10; $i++) {        // The variable $i is equal to a range between 1 and 10
select -r ("nurbsSphere"+$i);
duplicate -rr -un;
move -r 3 0 0 ;
}


Animate a displacement map from Sculp Geometry Tool with tiff files
Works better without frame padding
//Make 5 nurbs 50 x 50 section planes, add a displacement image and make them invisible, add keyframe on and off
int $i;
for ($i = 1; $i <= 5; $i++) {
        nurbsPlane -p 0 0 0 -ax 0 1 0 -w 1 -lr 1 -d 3 -u 50 -v 50 -ch 1;
        select -r ("nurbsPlane"+$i);

        SculptSurfacesToolOptions;
        artPuttyCtx -e -maxdisp 0.1 `currentCtx`;
        artImportAttrMapCB artPuttyCtx ("E:/maya/sourceimages/numbers9999/numbers."+$i+".tif") "image";       
       
        string $n = "nurbsPlane";
        string $v = ".visibility";
        string $vv = ".v";

        currentTime ($i - 1);
        setAttr ($n + $i + $v) 0;     //vis off
        setKeyframe ($n + $i + $vv);

        currentTime ($i);
        setAttr ($n + $i + $v) 1;     //vis on   
        setKeyframe ($n + $i + $vv);

        currentTime ($i + 1);
        setAttr ($n + $i + $v) 0;     //vis off 
        setKeyframe ($n + $i + $vv);
};

A script to advance 1 frame up to 150, Select a model named cloth3 and copy it
int $f = 0;
while ($f <= 150) {
playButtonStepForward;
select -r cloth3_;
duplicate -rr;
$f += 1;
};