Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
71 views4 pages

Mel Attribute in Maya

The document provides an overview of using MEL (Maya Embedded Language) for modeling and animation in Maya, detailing how to access and manipulate nodes and attributes. It covers the use of the Script Editor, creating shelf buttons, and managing attributes through the Channel Box and Attribute Editor. Additionally, it discusses making connections between attributes and using expressions for animation, along with resources for further learning.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views4 pages

Mel Attribute in Maya

The document provides an overview of using MEL (Maya Embedded Language) for modeling and animation in Maya, detailing how to access and manipulate nodes and attributes. It covers the use of the Script Editor, creating shelf buttons, and managing attributes through the Channel Box and Attribute Editor. Additionally, it discusses making connections between attributes and using expressions for animation, along with resources for further learning.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

MEL & Attributes in MAYA

Notes
• In general, use Help->Tutorials and Help->Maya Help
• For syntax, use Help->Maya Help; search "MEL" and find 'MEL for programmers"
• This discussion will cover various ways to use MEL to model and animate in Maya
• Search web for 'Maya MEL scripts' - many resources on-line; e.g.,
- highend3d.com/maya/downloads/mel_scripts/animation

Introduction
Ways to work in Maya
• Interactively
• MEL scripting
• C++ API
MEL - Scripting language w/ objects & attributes. Maya is implemented in MEL !
• typical control statements, variables, expressions, etc. (see tutorials)
• access Maya representation of nodes connected to each other
To see nodes, make some polygonal objects, group some together, then view node
structure use Window->Hypergraph...
scene object hierarchy: Directed Acyclic Graph (DAG)
nodes & connections: Dependency Graph (DG)
MEL commands can be typed in MEL command line, for example,
sphere;

Script Editor
Use icon (window w/ horizontal dividing line) in lower right of Maya window
or Window->General Editors->Script Editor
Sections of Script Editor: history, input
type commands in input section, for example,
$i = 0;
sphere;
move -r 0 $i 0;
$i = $i+1;
After typing in, to execute it use CNTRL-Return; history section give Maya response to
commands; use Script Editor File->Echo All to see everything executed by Maya.

Shelf Button
Make new shelf by using Window->Settings/Preferences->Shelfs..
highlight 2rd-4th commands & CNTRL-click drag to shelf to make it a button
hit button several times
Script File
make text file (e.g., testScript.mel) containing:
for ($j=0; $j<10; $j++) {
sphere;
move -r 0 $j 0;
}
in Script Editor window, File->Source Script... to read in and execute script

UI
Maya also has facilities to create a User Interface using MEL (but not dealt with here)

Attributes
are quantities of a node - e.g., sphere's transform node contains translation in x attribute
reference using nodename.attributename: e.g. mySphere.translateY or mySphere.ty
MEL commands: listAttr, getAttr, setAttr, aliasAttr; type some of following & note results
in history section of Script Editor
sphere;
move -r 10 20 10;
getAttr nurbsSphere1.translateY;
getAttr nurbsSphere1.tx;
listAttr nurbsSphere1;
setAttr nurbsSphere1.tz 5;
aliasAttr up nurbsSphere.ty;
getAttr nurbsSphere1.up;
keyable v. non-keyable attributes: keyable are attributes that can be keyframed
Channel Control Editor: controls keyability of attributes
Window->General Editors->Channel Control...
Channel Box: info about object's transform node, shape node, input node
Display->UI Elements->Channel Box/Layer Editor
displays keyable and displayed non-keyable attributes
can edit keyable attributes, e.g., set translate x to specific numeric value

Attribute Editor
edit more attributes of object than Channel Box e.g., change name of objects
delete all objects, make sphere, rename sphere to ‘mySphere’; make cone and rename
it to ‘myCone’
Window->Attribute Editor
add custom attributes e.g., weight, Modify->Add Attribute
Connections
can make *connection* from one object attribute to another object's attribute
use Connection Editor: Window->General Editors->Connection Editor..
select mySphere, in Connection Editor, Reload Left (from)
select myCone, in Connection Editor, Reload right (to)
select translate y from left side and translate x from right side
if AutoConnect is selected (indicated by italicizing attributes) connection is made; else
need to select hit Connect button at bottom (select AutoConnect under File)
interactively move mySphere up and down to see effect
make connection in MEL by typing in the following in command line or script editor:
connectAttr mySphere.tx myCone.ty;
and interactively move 'mySphere' around to see effect

Animation Expressions
Expressions are executed each frame. In command line type the following & hit play
expression -s “mySphere.translationX = sine(time);”
Expressions can be set up in scripts (Procedural Animation!). Make file script with:
// http://www.fundza.com/mełquickref2/#expression1
// NOTE: `spherè returns 2 strings. that’s why $obj is an array
// and why $obj[0] is used in the expression
string $exp = “”;
string $obj[];
for($i = 0; $i < 3; $i++) {
$obj = `spherè;
move (rand(-3,3)) (rand(-3,3)) (rand(-3,3));
$exp += “select -r “ + $obj[0] + “;\n” +
“move -moveY (rand(0,2));\n”;
}
$exp += “select -clear;\n”;
expression -s $exp -ae 1;
playbackOptions -min 1 -max 30;
play;
Source the script and see the animation
To Edit and manage expressions Window->Animation Editors->Expression Editor...
Select object, select expression, edit the expression, then hit 'Edit'
in Maya->Help, find & read "Differences between expression and MEL syntax"

You might also like