2009

Table Of Contents
Using expressions to control multiple attributes . . . . . . . . . 571
Linking multiple attributes on the same object . . . . . . . . . . 571
Controlling attributes in two objects . . . . . . . . . . . . . . . 572
Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 573
Lesson 2: Conditional expressions . . . . . . . . . . . . . . . . . . . . 574
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574
Creating a conditional expression . . . . . . . . . . . . . . . . . 574
Other conditional statement options . . . . . . . . . . . . . . . 577
Fixing a problem in an expression . . . . . . . . . . . . . . . . . 579
Using else statements . . . . . . . . . . . . . . . . . . . . . . . 580
Simplifying expressions . . . . . . . . . . . . . . . . . . . . . . 581
Editing expressions to refine an animation . . . . . . . . . . . . 582
Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 584
Lesson 3: Controlling particle attributes . . . . . . . . . . . . . . . . 584
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584
Creating particle objects . . . . . . . . . . . . . . . . . . . . . . 584
Using creation expressions to set a constant color . . . . . . . . 586
Using runtime expressions . . . . . . . . . . . . . . . . . . . . . 587
Modifying runtime expressions . . . . . . . . . . . . . . . . . . 588
Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 589
Chapter 13
Scripting in Maya . . . . . . . . . . . . . . . . . . . . . . . . 591
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
Some basic concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . 592
Preparing for the lessons . . . . . . . . . . . . . . . . . . . . . . . . . 595
Lesson 1: Commands in MEL . . . . . . . . . . . . . . . . . . . . . . 596
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
Entering MEL commands . . . . . . . . . . . . . . . . . . . . . 597
Observing script history . . . . . . . . . . . . . . . . . . . . . . 598
Modifying object attributes . . . . . . . . . . . . . . . . . . . . 601
Editing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 605
Lesson 2: Saving scripts to the Shelf . . . . . . . . . . . . . . . . . . . 606
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606
Setting up the scene . . . . . . . . . . . . . . . . . . . . . . . . 607
Recording the script history . . . . . . . . . . . . . . . . . . . . 608
Compare the rendered images . . . . . . . . . . . . . . . . . . 610
Saving the history as a button . . . . . . . . . . . . . . . . . . . 611
Beyond the Lesson . . . . . . . . . . . . . . . . . . . . . . . . . 613
Lesson 3: Using Variables in MEL . . . . . . . . . . . . . . . . . . . . 614
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614
Setting up the scene . . . . . . . . . . . . . . . . . . . . . . . . 615
Storing scene information . . . . . . . . . . . . . . . . . . . . . 615
Create a row of barrels . . . . . . . . . . . . . . . . . . . . . . . 617
Stacking the row of barrels . . . . . . . . . . . . . . . . . . . . . 618
Using MEL built-in functions to calculate the Y offset . . . . . . 619
Contents | xiii