Duplicating Maya 2017 Renderlayer

814 views
Skip to first unread message

Andreas Böinghoff

unread,
Oct 11, 2016, 9:27:55 AM10/11/16
to Python Programming for Autodesk Maya
Hey Guys,
we are new to Maya and asked us,if there is a scripted way to duplicate the current renderlayer (in Maya 2017) via script. I already found a way to create a new layer+collection+override, but I was not able to duplicate the current renderlayer with all collections and overrides. Has someone a code snippet for me that explains how I do that.
Thanks,
Andy


Justin Israel

unread,
Oct 12, 2016, 11:50:38 PM10/12/16
to Python Programming for Autodesk Maya
Hey there,

Sorry that you haven't seen a reply yet to your question. One of the helpful ways of figuring out how to replicate a user action in code is to open the Script Editor and enable the "Echo All Commands" option under the History menu. Then when you perform an action in the Maya UI, you can see what code is being triggered. Doing so may either tell you directly what command you can run, or it may help point you at a mel script to look into. 

For instance, if I duplicate a render layer (in Maya 2016), I find out that the following mel command is used:

renderLayerEditorCopyLayer RenderLayerTab <layer name>

I can run this directly, and it will duplicate the named render layer:

import maya.mel as mm
layerName = "layer1"
mm.eval("renderLayerEditorCopyLayer RenderLayerTab {}".format(layerName))

If I wanted to know more details about this mel command, I could do this (in mel):

whatIs renderLayerEditorCopyLayer

And it would either tell me it is a builtin command and has no source file, or tell me the mel script that defined the proc. In this case, it tells me that it is defined by Maya, in its startup/scripts/layerEditor.mel

Hope this helps.

Justin

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/acf61b7d-f838-42f4-a7e4-2438f3f4b48b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andreas Böinghoff

unread,
Oct 14, 2016, 3:48:34 AM10/14/16
to Python Programming for Autodesk Maya
Hey Justin,
thanks for the good tricks and advises. Unfortunately your piece of code seems only to work for the Legacy Render Layers. If I run that command within maya 2017, the renderlayer is copied, but it is not showing up in the new Render Layer Editor. 

Here is my way how I create a new Renderlayer + Collection + 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

Can I find somewere if the "renderSetup.model.renderSetup.instance()" has a duplicate fuction?
Reply all
Reply to author
Forward
0 new messages