View Full Version : get selected renderlayers

01 January 2011, 06:20 PM
Hi all,

I need to get a list of selected renderlayers in the renderLayerTab of the Maya GUI.
In ...\Maya2011\scripts\startup\layerEditor.mel I found a function called getLayerSelection which seem to do the job.
global proc string [] getLayerSelection(string $type)
// Description:
// Return the current layer selection for the specified layer type.
// Arguments:
// $type - Valid values are: "Display", "Render", or
// an emtpy string. In the case of an empty string the
// current layer type displayed in the editor will be used.
// Returns:
// A string array containing the names of the selected layers.
But is throws an error:
string $layers[]; $layers = `getLayerSelection("Render")`;
print $layers;
// Error: file: C:/Program Files/Autodesk/Maya2011/scripts/startup/layerEditor.mel line 5315: Invalid layer type: Render
Did the layer type for renderlayers change? With Display as type I get a list of the selected displaylayers.
Any ideas? Some help would be nice...

01 January 2011, 10:25 AM
took a look at that script. I suppose something has changed, or perhaps that never worked.

If you want to get selected render layers you could just do:

string $sel[] = `ls -sl`;
select -cl;
for($o in $sel)
if(`objectType $o` == "renderLayer")
select -add $o;

01 January 2011, 06:20 PM
thanks for your reply greatPumkin.

'ls' was also my first try. But selected renderlayers via the renderlayer tab (see screenshot) aren't really selected. So you can select objects in the scene AND some renderlayers e.g. to add the objects to all selected renderlayers.
This is what i want to do...

CGTalk Moderation
01 January 2011, 06:20 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.