Accessing Display Layers [MEL]



Display Layers are used within maya to logically group a collection of objects. An animators main use of layers, is usually to group sets of animation controls together. There is however a lot of scope to use layers to say group the transforms which you will export animation for; or to split the character into upper and lower body bone sets etc. Ultimately each layer node will be connected to the items that are a part of that layer. To find this set of objects we merely need to query all outgoing connections.






// create an iterator to go through all meshes
void OutputDisplayLayers()

// iterate through all display layers
MItDependencyNodes it(MFn::kDisplayLayer);

for( ; !it.isDone(); )


// attach a function set to the layer
MFnDependencyNode fn(it.item());

// ignore the default layer
if( == "defaultLayer" ) continue;

cout << "LAYER " << << " {\n";

// get connections to attributes on the layer node.
// The LayerConnections will be a set of attributes
// on the LayerNode that are connected to something else.

MPlugArray LayerConnections;

// loop through all of the connections to the layer
for(unsigned int i=0;i<LayerConnections.length();++i)


// get the attribute plug on the other node so
// we can find out what it's connected to.

MPlugArray ConnectedNodes;
for( unsigned int j=0;j<ConnectedNodes.length();++j)


// attach a function set to the layer item.
MFnDependencyNode fnItem(ConnectedNodes[j].node());

// write the name of the item
cout << "\t" << << endl;


cout << "}" << endl;





What Next?

Render Layers


Rob Bateman [2004]