Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

How to create a Render Setup Layer with maya cmds ? (Maya 2016 Ext 2+) (python)

How to create a Render Setup Layer with maya cmds ? (Maya 2016 Ext 2+) (python)

Anonymous
Not applicable
6,234 Views
10 Replies
Message 1 of 11

How to create a Render Setup Layer with maya cmds ? (Maya 2016 Ext 2+) (python)

Anonymous
Not applicable

Hello !

 

I can't seem to find how to create a Render Setup Layer with maya cmds. ('renderSetupLayer')

 

When I create a Render Setup Layer with the new Render Setup window the Script Editor doesn't echo the commands (only some results). Also I can't seem to find documentation about maya cmds related to this new feature.

 

With the Legacy Render Layer I would only have to do it like this : 

 

maya.cmds.createRenderLayer(n="myLayerName")

But now there is a Render Layer and a Render Setup Layer. Creating only the Render Layer will produce errors when changing layers in the Render Settings window and won't add a new Render Setup Layer.

 

 

Your help would be greatly appreciated !

 

0 Likes
Accepted solutions (1)
6,235 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable

I don't fully understand what you mean when you are saying you only get results, can you explain?

 

The doc for createRenderLayer is found here: http://download.autodesk.com/us/maya/2011help/Commands/createRenderLayer.html

0 Likes
Message 3 of 11

Anonymous
Not applicable

@Anonymous - That is what I get from the script editor when I add a render layer setup manually (nothing useful as far as I could tell) :

Spoiler
MASHnewNodeCallback( "renderSetupLayer1");
from maya import OpenMaya as om; om.MFileIO.isReadingFile()
# Result: False # 
mayaHasRenderSetup;
// Result: 1 // 
setFilterScript "initialShadingGroup";
// Result: 0 // 
setFilterScript "initialParticleSE";
// Result: 0 // 
setFilterScript "defaultLightSet";
// Result: 1 // 
setFilterScript "defaultObjectSet";
// Result: 1 // 
mayaHasRenderSetup;
// Result: 1 // 
mayaHasRenderSetup;
// Result: 1 // 
mayaHasRenderSetup;
// Result: 1 // 
mayaHasRenderSetup;
// Result: 1 // 
mayaHasRenderSetup;
// Result: 1 // 
mayaHasRenderSetup;
// Result: 1 // 
mayaHasRenderSetup;
// Result: 1 // 
mayaHasRenderSetup;
// Result: 1 // 
mayaHasRenderSetup;
// Result: 1 // 
mayaHasRenderSetup;
// Result: 1 // 
mayaHasRenderSetup;
// Result: 1 // 
updateUnifiedRenderGlobalsWindowSpecifiedUI;
control -edit -enable false multiCamCustomToken;
// Result: multiCamCustomToken // 
updateLayerChangeMultiCameraNamingScriptJob;
updateUnifiedRenderGlobalsWindowSpecifiedUI;
control -edit -enable false multiCamCustomToken;
// Result: multiCamCustomToken // 
updateMultiCameraBufferNamingMenu;
control -edit -enable false multiCamCustomToken;
// Result: multiCamCustomToken // 

The createRenderLayer cmds works for Legacy render layers but doesn't seem compatible with the new system.

 

But good news ! I actually found a way to create a render setup layer, a collection and an override:

from maya.app import renderSetup
renderSetup.model.renderSetup.initialize()
rs = renderSetup.model.renderSetup.instance()
ov = renderSetup.model.override

# Create layer, collection, override
layer_obj = rs.createRenderLayer('MyFirstLayer')
collec_obj = layer_obj.createCollection('MyFirstCollection')
over_obj = collec_obj.createOverride('MyFirstOverride', ov.AbsOverride.kTypeId) #absolute

 

Bad news are I don't know how to :

1 - Add objects from the outliner in a Collection

2 - Add an attribute to an Override

 

Any idea ? Smiley Indifferent

Message 4 of 11

Anonymous
Not applicable

1 - Add objects from the outliner in a Collection

The objects in the outliner are 'nodes' / 'Scene objects' you can get all of them from the scene with: 

 

# list all objects
collection = [] collection = cmds.ls()

http://download.autodesk.com/us/maya/2011help/CommandsPython/ls.html

 

2 - Add an attribute to an Override

I have not dealt with this either, 

0 Likes
Message 5 of 11

Anonymous
Not applicable

I'm actually talking about adding a node from the Outliner to a Collection under the render setup layer :

 renderSetupCollection.PNG

 

0 Likes
Message 6 of 11

Anonymous
Not applicable
Accepted solution

Found it if anyone is interrested :

 

# Add a list to a collection
collec_obj.getSelector().staticSelection.set(['pCube1', '|pCube2'])
# Add an attribute to an override
setover_obj.finalize('defaultRenderQuality.shadingSamples')

 

0 Likes
Message 7 of 11

Anonymous
Not applicable

Hey Guys, we have a problem here that fits good to this topic. Has someone of you a code snippet for duplicating an existing renderlayer in maya 2017? There is no option exposed in the ui and I can't find any documentation on that topic.

Thanks!

Andreas

0 Likes
Message 8 of 11

Anonymous
Not applicable

I didn't find a copy/paste, but a work-around could be to select your layer's collections and 'export Selected', create a new layer and 'Import user templates'. 

0 Likes
Message 9 of 11

Anonymous
Not applicable

Hey Olivier, thanks for your replay. I already know that trick, but our artists find it quite unpractical. A hotkey that fires a command would be much more practical.

0 Likes
Message 10 of 11

Gen_T
Enthusiast
Enthusiast

Stumbled onto this thread and after some digging around in the code, I thought I'd share this.

The method myCollection.getSelector().staticSelection.set(["objA", "objB"]) replaces the items in the collection instead of appending the list. To add objects to the collection, use the .add() method.  Just make sure your strings are in absolute "long name" format.

so...

myCollection.getSelector().staticSelection.add(maya.cmds.ls(objsList, long =True))

 

 

 

0 Likes
Message 11 of 11

5rivamsi
Contributor
Contributor

Hello sir,

How can I list objects in a render layer.

I tried "editRenderLayerMembers" and mentioned "name" of the render layer. Then an error says, "name" is not a render layer.Kindly help.