Maya summary

Summary of elementary Maya feature.



alt + left click Rotate
alt + middle click   Strafe / pan
alt + right click Zoom
F Focus on selection






S Insert key frame


Maya works on nodes. Nodes have attributes which we connect together using MEL or Python scripts.
Maya GUI calls those script to setup the nodes.

MEL script


Variables are always prefixed with '$' when declared and used:

for loops:

for( $i=0, $j=0.0; $i<10; ++$i, $j+=0.75 ){

Array /multi attributes

How to describe a plug:

string $plug_name = "some_node_name.some_attr_name[index_atrr].some_compound_name"

Check connection at index:

Is a source {array} attribute currently connected to a node? This can be use to determine if an index of an array attribute is free and can be safely connected with connectAttr().

string $con = `connectionInfo -sourceFromDestination ("some_node_name.some_attribute[index]")`;
if( size( $con ) == 0){ /* Yea I'm free */ }

Find first available connection:

getNextFreeMultiIndex("some_node_name.some_attr_name") // N.B: no need to define index with [idx]

Remove element at index:

// This will remove the element with index 4 from the input of 
// the choice node as long as there are no incoming or outgoing 
// connections to the attribute. 
removeMultiInstance choice.input[4]; 
// This will remove the element with index 100 from the input of 
// the choice node, breaking any existing connections first.
removeMultiInstance -b true choice.input[100];

c.f maya2014/scripts/AETemplates/AEnewNonNumericMulti.mel and AEremoveMultiElement()

Get the size of the array attribute:

getAttr -size "some_node_name.some_attribute" // N.B: no need to define index with [idx]

List the currently used attribute:

listAttr -multi $plug_name

Source of inspiration to understand how to handle multi-attributes:


Check out functions like: AEnewNonNumericMultiAddNewItem(), AEremoveMultiElement()


Get number of vertices of a mesh:

polyEvaluate -v  "pCylinder1Shape";


MEL syntax (quite good and concise):



Every data (DAG nodes, lights etc.) are represented as MObject in Maya. Instead of converting the MObject to some specialized type we use function sets MFnXxx(). To access the methods of a specialized type we must use a function set:

MFnAttribute attribute( mObject ); // bind object to functions; // use object's functions
// We can also bind the function set like so:
attribute.setObject( mObject );


Display information in Maya script console: MGlobal::displayInfo("some infos");

Look up the DAG (scene tree), you can start from an arbitrary node with reset, use breadth or depth first order and check the current depth of the iterator (0 for root):

MItDag aItDag(MItDag::kDepthFirst);
aItDag.reset(iNode.mDagPath.node(), MItDag::kDepthFirst);
for(; !aItDag.isDone();
    MDagPath aDagPath;
    MFnDagNode fnNode( aDagPath ); // Get the DAG node
    MString str = fnNode.typeName(); // Get its type for instance "transform" or "joint"
    aItDag.depth();// Depth in the scene tree

Alternate way to look up the scene tree:

void rec_tree(const MFnDagNode& fnNode)
    for(unsigned i = 0; i < fnNode.childCount(); ++i) {
        MObject obj = fnNode.child( i );		
        ret_tree(obj); // Sometimes this conversion fails between MFnNode and MObject wherase the dag iterator works well TODO: search why.

Fetch attribute value of a node:

MFnDependencyNode fn( dagPath );
// get the MPlug for the tx attribute
MPlug plug = fn.findPlug("tx");
// get the value from the plug
float tx;

Custom nodes: Construction: Never call Maya API in the custom node. Instead override the method: postConstructor() Destruction: When removing a node with deleteNode the key stroke del etc. you only remove the node from the dependency graph and the node is placed onto the undo list. The destructor will not be called unless the node disappear from the undo list (list flush/overflow, new scene) Removal from the dependency graph can be detected with various callbacks, see: MDGMessage:: MNodeMessage::addNodeAboutToDeleteCallback etc.

No comments

All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Anti-spam question: