The Expression Editor
Although you can create and edit expressions using the MEL command expression, it is often more convenient to do so using the Expression Editor (Figure 12.05). We'll cover a few of this important editor's key features here. The Select Filter menu lets you choose how items are listed:
1. ByExpressionName:
for example, expressionl
2. By Object/Attribute Name:
displays attributes and expressions (if any exist) for selected objects
3. ByScriptNodeName
(a Script Node is a DG node which stores a MEL script)
The Editor menu lets you choose to edit your expressions in the Expression Editor or in a default text editor on your system. For more information on using this feature, refer to Maya's Help Library:
^ Linking an external text editor to Maya's Expression Editor
Maya Help ^ General ^ MEL and Expressions ^ Animation expressions ^ Edit an animation expression with a text editor
Edit View Bookmarks Graph Rendering Options Show help
"St
Time node
Time node
Transform node sends the state of its driven attribute to the Expression
|
expressionl |
1 |
J~j mySphere | |||
|
Expression node |
Expression drives an attribute of the connected transform node | ||||
Converting units
When Maya assigns and queries an attribute or internal variable whose value is a measurement unit—distance, playback speed, or an angle—the program does so using its default internal units of centimeters, 24 fps, and radians, respectively. If you alter any of these default working units in Preferences, Maya converts the attribute values that you specify to its default working units behind the scenes. For example, suppose you changed the Angular working units from radians to degrees—like you did back on page 266. When you assign a Rotation attribute value for an object, Maya will convert that value from degrees to radians for storage in the object's transform node. The attribute value will still be displayed in degrees in the Channel Box (and other UI editors, such as the Attribute Editor), but Maya will work with its equivalent value in radians for any calculations it makes in order to animate the rotation of the object.
The Convert Units settings in the Expression Editor tell Maya whether or not to convert All three types of unit, None of the three, or Angular (units) only. When you specify None. Maya will treat all distance units as centimeters and all angles as radians, regardless of the working units you specified in Preferences. When you specify All or Angular only, and set the default working units in Preferences, Maya will not convert units. In other words, unit conversion in animation expressions only happens when you're using non-default working units (set in Preferences) and specify unit conversion other than None in the Expression Editor.
Converting from non-default units adds extra computation steps and can therefore slow down the execution of an animation expression. For optimal speed, it's best to set working units in Preferences to their default values of centimeters, 24 fps, and radians. However, this is not always practical: you may find it more intuitive to work with angles in degrees rather than radians, and your project may call for distance units other than centimeters. Therefore, the choice of working units comes down to a trade-off between convenience and speed.
The Create and Edit buttons
Maya won' t create or update an expression node until you press either the Create or Edit buttons at the bottom of the Expression Editor. Because of this requirement for manual intervention, via the UI it is easy to lose changes you've made while editing an expression. The Reload button reloads from memory the version of the expression that was stored last time you pressed the Edit button; it allows you to undo changes to an expression before pressing Edit.
You will get to know the Expression Editor quite well as you work through this book. For complete documentation, refer to the Help Library:
^ The Expression Editor
Maya Help ^ General ^ MEL and Expressions ^ MEL Windows and Editors ^ Expression Editor
Post a comment