[ MEL Scripting for Maya Animators Cover Image ]

MEL Scripting for Maya Animators

Mark R. Wilkins and Chris Kazmier

Supplementary Material

Scripts  Scene Files  Errata



Scripts (Updated March 23, 2003)

These compressed archives contain the scripts used in the book.  When a script file is named Chapter<number>.mel, you should work through the example in the chapter using the .mel file as reference only.
The other scripts can be executed in full using the Script Editor's "Source Script..." command, though you may have to work through certain steps prior to executing the scripts to see what's depicted in the chapters.

These scripts include all of the corrections made in the errata listed below.

For Windows or Macintosh:
MSMA_scripts.zip (38k)

For Irix or Linux:
MSMA_scripts.tar.gz (17k)

Scene Files

Example scene files:
These compressed archives contain all of the scene files required for the examples in Chapter 16, Chapter 17, and Chapter 19.

For Windows or Macintosh:
MSMA_example_scenes.zip (2.2 MB)

For Irix or Linux:
MSMA_example_scenes.tar.gz (2.2 MB)

Note:  Users of Maya 3.0 or 3.5 should use mrBlah.ma instead of mrBlah.mb for the character rigging examples in Chapter 19



Errata (Updated August 29, 2003)


Have you found errors in the scripts that are not listed here?  If so, please send us an e-mail at
errata@melscripting.com


How to Determine What Printing You Have


On the copyright page, opposite the first page of the Contents, a few lines below the copyright date, you will see a row of numbers.  If the numbers read:

07    06    05    04    03     5    4    3    2   1

then you have the first printing.


If the numbers read:

07    06    05    04    03     5    4    3    2

then you have the second printing.  The second printing does not contain any new material, only fixes to errors in the text.



Errata for the First Printing


Preface

Page xvii

Stephan Osterburg's contribution was essential to both examples in Chapter 19, not just the second.


Chapter 1: Maya Under the Hood

Page 2

The document (and help menu item) that was called the DG Node Reference in Version 3 is now called the Node and Attribute Reference in Version 4


Page 10 (added 8/10/03)

To make what you see in the Hypergraph match Figure 1.12, the instructions on pg. 10 should include an extra step:  choose Show > Show Auxillary Nodes.

Chapter 3: Using Expressions


Page 57

In the second paragraph, the sentence that reads:
When coordination is set to 0, we want nurbsSphere1 to point only at target1, and nurbsSphere2 to point only at target0.
should read

When coordination is set to 0, we want nurbsSphere1 to point only at target1, and nurbsSphere2 to point only at target2.


Chapter 4: Controlling Particles with Expressions

Page 71

The expression is missing a trailing curly bracket }, and should read:
if (tz > -5) {
    magnitude = 5.0;
} else {
    magnitude = -35.0;
}


Chapter 5: Problem Solving with MEL Scripting

Page 110  (added 8/10/03)

In the portion of the script at the top of the page,

"(" + $curveSelected +
    "particlesShape.scaleOffset * sin(" +
    $curveSelected + "particlesShape.age*20));\n";

should read:

"(" + $curveSelected +
    "particlesShape.scaleOffset * $norm2vec * sin(" +
    $curveSelected + "particlesShape.age*20));\n";


This code is correct in the listing at the end of the chapter and in the supplementary files.


Chapter 6: Variables and Data Types

Page 130  (added 7/17/03)

The second print statement reads

print ( ($a > ($b - $slop) ) || ($a < ($b + $slop) ) ); // returns 1

but should read:

print ( ($a > ($b - $slop) ) && ($a < ($b + $slop) ) ); // returns 1




Chapter 7:  Using MEL Commands

Page 143
string $condNodeNames[] = cone("-name", "testing2");
should read
string $coneNodeNames[] = cone("-name", "testing2");



Chapter 8:  Manipulating Nodes in MEL
Page 149  (added 8/10/03)

In the second line of code at the top of the page,

string $selected_joints[] = `ls -sl *joint*`;

should read

string $selected_joints[] = `ls -sl "*joint*"`;


Page 152

The section entitled Creating Nodes in a MEL Scene should be called Creating Nodes in a Maya Scene


Page 156

The document (and help menu item) that was called the DG Node Reference in Version 3 is now called the Node and Attribute Reference in Version 4


Chapter 9:  Controlling the Flow of Execution
Page 167  (updated for clarity, 8/29/03)

The first code block (unindented) should read

if ($number < 30)
{
if ($number < 20)
{
print ("It's less than 20!\n");
if ($number == 13)
{
print ("It's 13!\n");
}
}
else {
print ("Hmm, I think it's between 20 and 30?\n");
}
}


and the second should read:


if ($number < 30)
{
    if ($number < 20)
    {
        print ("It's less than 20!\n");
        if ($number == 13)
        {
            print ("It's 13!\n");
        }
    }
    else {
        print ("Hmm, I think it's between 20 and 30?\n");
    }
}



Chapter 10:  Procedures and Functions
Page 183

Example 2: Geometry-Constrained Locators initially promises that the locators will be geometry-constrained and then normal-constrained, but instead uses an aim constraint in the actual example.  The resulting difference is generally not relevant to the principles presented in the chapter.


Chapter 13:  Simple MEL User Interfaces


Page 226

In the script hunt_for_blah, the line
int $found_match = ! `strcmp "blah" $typedString`;
should read

int $found_match = ! `strcmp "blah" $matches_blah`;




Page 232

The command to run the script is incorrect.  Instead of
makeSpheres();
it should read
makeSpheresUI();

Chapter 14:  Custom Dialog Boxes

Page 263

Near the top of the page, the lines
button -label "Sphere" -command "buttonAction(1, $positionGrp)";
button -label "Cone" -command "buttonAction(2, $positionGrp)";
button -label "Cube" -command "buttonAction(3, $positionGrp)";
should read

button -label "Sphere" -command "buttonAction(1, $positionGroup)";
button -label "Cone" -command "buttonAction(2, $positionGroup)";
button -label "Cube" -command "buttonAction(3, $positionGroup)";
These lines are correct in the full listing of the procedure on pg. 264.


Chapter 16:  Examples Using MEL with Particle Dynamics

Page 284

The text refers to setting the playback end time to 200 but offers the MEL command

playbackOptions -min 1 -max 360;

The text should say "set your playback start time to 1 and your playback end time to 360" etc.


In the first line of the "Per Particle Arrays" section, the text reads "Access the Per Particle (Array) Attributes section and click the General button."  It should read "Access the Add Dynamic Attributes section and click the General button."


Page 293

The comment // Changed to only V should be deleted

Page 304

The message that Maya prints when executing the line beginning with float $Pstart[] is only this:
// Result: 0 5 14 //

Page 312

The first line of code on the page that reads
if (size($planes != 4) {
should read
if (size($planes) != 4) {

Page 312

The fifth and sixth lines of code that read
float $Pstart = `xform -q -a -translation $planes[0]`;
particle -n Ball -p $Pstart[0] $Pstart[1] $Pstart[2] -cl;

should read
float $Pstart[] = `xform -q -a -translation $planes[0]`;
particle -n Ball -p $Pstart[0] $Pstart[1] $Pstart[2] -c 1;



Chapter 17:  Examples Using MEL with Solid Body Dynamics

Page 324

The MEL code that reads:
xform -a translation 0 -3 -3 Floor1;
xform -a rotation 26 0 0 Floor1;

should read
xform -a -translation 0 -3 -3 Floor1;
xform -a -rotation 26 0 0 Floor1;


Page 328

The lines on the page that read:
string $pObject + [] = `particle`;
connectDynamic -emitter $eObject[0] $pObject[0];
should read
string $pObject[] = `particle`;
connectDynamic -emitters $eObject[0] $pObject[0]



Chapter 18:  Example of a Simple Crowd System
Page 389

Not all the new code is correctly marked in boldface.  In particular, everything after

// Add vehicle force field for follower

on page 389 is new code


Page 393

The curly bracket after cycleCheck -e off; should be in boldface to indicate that it's new code.


Page 405

The line that reads:
string $collectObjects = `ls -sl`;
should read
string $collectObjects[] = `ls -sl`;

Pages 406

The sentence that reads "This command will print out  -150, the value in the 1st row and 3rd column" should read "This command will print out  -150, the value in the 4th row and 1st column."


Pages 406 and 409 


The line that reads:
radial -name ("Gforce" + $compassForce[$i]
should read
radial -name ("Gforce" + $compassForce[$i])

Page 441

The line near the top that reads:
matrix $gFp[4][3] = <<0, 0, -150; 0, 0, 150; 150, 0, 0>>;
should read
matrix $gFp[4][3] = <<0, 0, -150; 0, 0, 150; 150, 0, 0; -150, 0, 0>>;




Errata for the Second Printing


Chapter 1: Maya Under the Hood


Page 10 (added 8/10/03)
To make what you see in the Hypergraph match Figure 1.12, the instructions on pg. 10 should include an extra step:  choose Show > Show Auxillary Nodes.


Chapter 5: Problem Solving with MEL Scripting

Page 110  (added 8/10/03)

In the portion of the script at the top of the page,

"(" + $curveSelected +
    "particlesShape.scaleOffset * sin(" +
    $curveSelected + "particlesShape.age*20));\n";

should read:

"(" + $curveSelected +
    "particlesShape.scaleOffset * $norm2vec * sin(" +
    $curveSelected + "particlesShape.age*20));\n";


This code is correct in the listing at the end of the chapter and in the supplementary files.


Chapter 6: Variables and Data Types

Page 130  (added 7/17/03)

The second print statement reads

print ( ($a > ($b - $slop) ) || ($a < ($b + $slop) ) ); // returns 1

but should read:

print ( ($a > ($b - $slop) ) && ($a < ($b + $slop) ) ); // returns 1



Chapter 8:  Manipulating Nodes in MEL
Page 149  (added 8/10/03)

In the second line of code at the top of the page,

string $selected_joints[] = `ls -sl *joint*`;

should read

string $selected_joints[] = `ls -sl "*joint*"`;


Chapter 9:  Controlling the Flow of Execution
Page 167


The first code block (unindented) should read

if ($number < 30)
{
if ($number < 20)
{
print ("It's less than 20!\n");
if ($number == 13)
{
print ("It's 13!\n");
}
}
else {
print ("Hmm, I think it's between 20 and 30?\n");
}
}


and the second should read:


if ($number < 30)
{
    if ($number < 20)
    {
        print ("It's less than 20!\n");
        if ($number == 13)
        {
            print ("It's 13!\n");
        }
    }
    else {
        print ("Hmm, I think it's between 20 and 30?\n");
    }
}




Chapter 10:  Procedures and Functions
Page 183

Example 2: Geometry-Constrained Locators initially promises that the locators will be geometry-constrained and then normal-constrained, but instead uses an aim constraint in the actual example.  The resulting difference is generally not relevant to the principles presented in the chapter.



Chapter 16:  Examples Using MEL with Particle Dynamics

Page 312

The fifth line of code that read
float $Pstart = `xform -q -a -translation $planes[0]`;
should read
float $Pstart[] = `xform -q -a -translation $planes[0]`;

Chapter 18:  Example of a Simple Crowd System

Pages 406

The sentence that reads "This command will print out  -150, the value in the 1st row and 3rd column" should read "This command will print out  -150, the value in the 4th row and 1st column."





melscripting.com © 2002, Mark R. Wilkins
portions of this material © 2002, 2003, Morgan Kaufmann Publishers, used with permission









1