MEL Scripting for Maya Animators


  • Mark Wilkins, DreamWorks Animation SKG, Glendale, CA, USA
  • Chris Kazmier, Sony Pictures Imageworks, Culver City, California, U.S.A.

Trying to learn Maya programming from the documentation can be daunting whether or not you are a programmer. The first edition of MEL Scripting for Maya Animators earned the reputation as the best introductory book on MEL, Maya’s scripting language. Now fully revised and updated, the second edition also includes new features, such as a discussion of global procedures, new chapters on fixing programming bottlenecks, advanced user interface techniques, and optimizing character rigs. New chapters on utility nodes and Maya's Web Panel feature provide new ideas on how to use MEL in applications. This new edition has kept the popular style of the first edition that offered very clear explanations of programming concepts to those without programming experience. A generous collection of code examples and Maya scene files is included on the companion Web site. This is a book for animators, artists, game developers, visual effects developers, and technical directors who want to learn the fundamentals of Maya, how to automate tasks, personalize user interfaces, build custom tools, and solve problems with MEL.
View full description


Technical and nontechnical animators, artists, game developers, visual effects developers, and technical directors.


Book information

  • Published: July 2005
  • ISBN: 978-0-12-088793-4


"Reading and following the lessons of this book provides one of the best ways for a casual Maya user to elevate their skills to a professional level. The fundamental techniques developed in MEL Scripting for Maya Animators are critical for visual effects artists to learn." — Scott Stokdyk, Visual Effects Supervisor, Sony Pictures Imageworks "While the first edition opened the doors to MEL scripting for interested Maya users, this expanded and updated second edition delves deeper into important programming concepts, and new features in Maya released since the original edition. No longer just for the first steps in MEL programming, this edition takes the reader into the depths of advanced topics such as user interface layout and web panels that are sure to make this book a frequently used and a welcome addition to any technical director's bookshelf." — Doug Cooper, Visual Effects Supervisor, DreamWorks Animation "MEL Scripting for Maya Animators is the set of keys you need to get under the hood of Maya. The book is well written for both technical and non-technical animators. It is an essential tool in making sophisticated animation not only possible but also practical." — Henry LaBounta, Senior Art Director, Electronic Arts "This new edition is – as was the first edition – the very best of an extremely small number of books that even attempt to cover the subject of scripting animation. The authors take great pains to explain where pertinent features, graphs, and editors are found, and to paint a picture of the interconnectivity of Maya’s various networked nodes. If you’re just getting started or are advanced enough to want the second edition’s beefed up content, there’s an empty spot for this book next to your monitor right now. But make sure there is enough space for a few pads of sticky notes and a couple of highlighting markers. You’ll want to ink this one up." — Game Developer, December 2005

Table of Contents

PrefaceSpecial Acknowledgment
Chapter 1 Maya Under the HoodIn this chapter you will learnWhy Look Under the Hood?The Dependency Graph, Attributes, and ConnectionsExample 1: Using the Hypergraph to Explore the Dependency GraphTransform Hierarchy and Parent/Child RelationshipsExamining the HierarchyTransform and Shape NodesExample 2: Exploring Transform and Shape Nodes, Instancing, and HistoryMEL and Maya’s User InterfaceWhat to Remember About How Maya Works Behind the Scenes
Chapter 2 The Basics of MEL CommandsIn this chapter you will learnCan I Use MEL Without Scripting?Command Line and Command Feedback LineCommand ShellScript EditorScript Editor Versus Command ShellScript Editor’s Messages as MEL CodeMaking a Shelf Button for a MEL ScriptSaving a MEL ScriptSeductive Dangers of the Status Message AreaThe whatIs CommandBasic Structure of MEL CommandsWhere to Find Information About Maya and MEL on the Internet NewsgroupsHow to Use MEL Scripts Found on the InternetWhat to Remember About How to Use MEL Without Writing Scripts
Chapter 3 Using ExpressionsIn this chapter you will learnWhat Is an Expression?How Does an Expression Work?Equals Sign: Equality and AssignmentHow Maya Implements ExpressionsIs Maya’s Expression Language the Same as MEL?When (and When Not) to Use an ExpressionDefining Relationships Between AttributesWhat Is Operator Precedence?Walkthrough of Maya’s Expression LanguageDefinitions of VariablesComputing the Values of AttributesAssigning Computed ValuesExample 1: EyesAnalyzing the ProblemPlanning the Eyes’ Animation ControlsWriting the ExpressionWhat to Remember About Using Expressions
Chapter 4 Controlling Particles with ExpressionsIn this chapter you will learnTwo Kinds of Particle Object Attributes: Per Object and Per ParticleAll About VectorsTwo Kinds of Expressions: Ordinary and ParticleExample 1: Ordinary Expressions and a Newton FieldExample 2: A Simple Particle ExpressionA Few Hints for Efficient Particle ExpressionsExample 3: Helical Particles Around a CurveWhat to Remember About Particle Expressions in Maya
Chapter 5 Problem Solving with MEL ScriptingIn this chapter you will learnMEL’s Role in Maya: Building ScenesStrategies for Planning MEL ApplicationsThe Simplest User InterfaceCreating, Editing, and Querying Nodes in MELAdding, Setting, and Getting Values of Attributes in MELConnecting Attributes in MELCreating and Connecting Expression Nodes in MELExample 1: Using MEL to Automate Setup for Spiral ParticlesWhat to Remember About Writing MEL Scripts
Chapter 6 Variables and Data TypesIn this chapter you will learnDeclaring Variables (and Not Declaring Them)Environment VariablesMEL Statements and Type CheckingSimple and Aggregate Data TypesWhat to Remember About Variables and Data Types in MEL
Chapter 7 Using MEL CommandsIn this chapter you will learnWhat Is a MEL Command?Structure of a MEL CommandUsing MEL Commands in MEL ScriptsAvoid Using MEL Commands in ExpressionsWhat to Remember About Using MEL Commands
Chapter 8 Manipulating Nodes in MELIn this chapter you will learnUsing ls Command to Find Nodes by Name or Other PropertiesUsing Select Command to Manage Object SelectionCreating Nodes in a Maya SceneFinding a Node’s Parents and ChildrenFinding Information on Node ConnectionsAbout Maya’s Node Types and the Node and Attribute ReferenceWhat to Remember About Managing Nodes in MEL
Chapter 9 Controlling the Flow of ExecutionIn this chapter you will learnControlling the Flow of Script ExecutionBasic Conditional Operations: if-else and switch LoopsWhat to Remember About Controlling the Flow of Execution in MEL
Chapter 10 Procedures and FunctionsIn this chapter you will learnTop-Down DesignExample 1: A Trip to the Grocery StoreWhat Are Procedures and Functions?Example 2: Geometry-Constrained LocatorsExample 3: Recursive AntennaWhat to Remember About Procedures, Functions, and Top-Down Design in MEL
Chapter 11 Naming Nodes, Scripts, and VariablesIn this chapter you will learnWhy Naming Conventions Are ImportantNaming ScriptsNaming VariablesNaming NodesExample 1: Adding a Name Prefix to Objects in a HierarchyExample 2: Changing Name Prefixes in a HierarchyWhat Are Namespaces?Strategies for Using NamespacesWhat to Remember About Naming Scripts, Variables, and Nodes
Chapter 12 Designing MEL User InterfacesIn this chapter you will learnWhat Is a User Interface?What Maya Users Expect to See from a MEL ScriptQuestions to Answer Before Designing a User InterfaceDesigning and Testing a User InterfaceStructure of a Dialog BoxWhat to Remember About Designing User Interfaces in MEL
Chapter 13 Simple MEL User InterfacesIn this chapter you will learnCollecting Information from UsersValidating User Input: When and WhyAsking for Confirmation with confirmDialogAsking User for Text String with promptDialogAsking User to Pick File or Directory with fileDialogHandling Warnings and Errors with Warning and Error CommandsUsing Regular Expressions and match to Validate DataHow Regular Expressions WorkValidating IntegersValidating Floating-Point NumbersValidating Object Names (Without Namespaces)Example 1: Simple Dialogs and Input ValidationWhat to Remember About Simple MEL User Interfaces and Input Validation
Chapter 14 Custom Dialog BoxesIn this chapter you will learnHow to Structure a Script That Uses a Custom Dialog Box for InputDialog Boxes and Their ContentsExample 1: Making the Example Dialog BoxCommon Types of ControlsCommon Types of LayoutsExample 2: Dialog Box for Making Geometric PrimitivesWhat to Remember About Building Custom Dialog Boxes in MEL
Chapter 15 Making Advanced Dialog Boxes with formLayoutIn this chapter you will learnWhy Use formLayout?Planning a Dialog Box for formLayoutUsing formLayout: OverviewUsing formLayout: Defining Placement Rules for UI ObjectsExample: Implementing a Dialog Box with formLayoutWhat to Remember About Making Dialog Boxes with formLayout
Chapter 16 Making Advanced Dialog Boxes with Web PanelsIn this chapter you will learnWhat You Need to Know Before You ProceedWhat Are Web Panels?Learning Web AuthoringHow a Dialog Box Built with Web Panels WorksPlanning a Dialog Box for Web PanelsCreating a Web-Based Dialog Box for MayaLaunching a Web-Based Dialog Box from MELExample 1: Implementing a Dialog Box using JavaScriptIdeas for Dialog Boxes Built with Web PanelsWhat to Remember about Making Dialog Boxes with Web Panels
Chapter 17 Improving Performance With Utility NodesIn this chapter you will learnWhat Is a Utility Node?When Should You Consider Using a Utility Node?How to Create and Connect a Utility NodeExample 1: Using the plusMinusAverage node to find the midpoint between two locatorsCommon Utility NodesWhat to Remember About Improving PerformanceWith Utility Nodes
Chapter 18 Installing MEL ScriptsIn this chapter you will learnInstalling a Script to Make It Available in All ScenesInstalling a Script to Run When Maya StartsInstalling a Script into a Script Node in a SceneInstalling Custom MenusManaging Button Shelves and Creating Custom Shelf IconsWhat to Remember About Installing MEL Scripts
Chapter 19 Examples Using MEL with Particle DynamicsExample 1: Introduction to Particle GoalsExample 2: Particle Goals on a SurfaceExample 3: Using Goals on Multiple SurfacesExample 4: Using Goals on Surfaces, Part 2
Chapter 20 Examples Using MEL with Solid Body DynamicsExample 1: Particle CollisionsExample 2: Collision EventsExample 3: Collisions Between Objects in Solid DynamicsExample 4: Solid Dynamics and Particles
Chapter 21 Example of a Simple Crowd SystemExample 1: Creating a VehicleExample 2: Vehicle InteractionExample 3: Vehicle EnvironmentExample 4: Fine Tuning and Completing the ScriptFull Script Reference: crowdSystem.mel
Chapter 22 Examples Using MEL in Character RiggingExample 1: Character ControlsExample 2: Building a Character User InterfaceFull Text of mrBlahControls.mel