query current layer in batch render process

57 views
Skip to first unread message

Juan Cristóbal Quesada

unread,
Jan 14, 2019, 3:41:30 AM1/14/19
to python_in...@googlegroups.com
Hi,

Im trying to  retrieve the current layer being rendered in a batch
render process within an interactive maya session.

currently im trying to do it like this:

string $current_render_layer = `editRenderLayerGlobals -q
-currentRenderLayer`;

And im setting this code as a mel script in the render options tab, as
"pre" script for preRenderLayerMel.

When i launch the batch render im getting among other things the frame
number being rendered but i keep getting

the same render layer name when rendering two different ones.

Im guessing this code is not actually querying the batch render process,
but the Maya GUI tab.

So my question is: how can i retrieve the current render layer that is
being rendered? Maybe there is another Maya API command that im not
aware of, or maybe in the render options scripts there are already some
global variables built in and the render layer would be one of those...

Thanks

Josh Carey

unread,
Jan 14, 2019, 2:48:02 PM1/14/19
to python_in...@googlegroups.com
this may or may not operate the same as the globals query, but worth a shot in your case.  

import maya.app.renderSetup.model.renderSetup as renderSetup
rs = renderSetup.instance()
layer =  rs.getVisibleRenderLayer()
# you can do all sorts of stuff/queries on the layer now...
layer.name()  # name of the layer

--
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/1f4ed9b7-151b-f4cf-9a55-2eeade4eb98e%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
Josh Carey


Juan Cristóbal Quesada

unread,
Jan 15, 2019, 3:16:27 AM1/15/19
to python_in...@googlegroups.com
Thanks Josh, but that doesnt work either, its querying the RenderSetup Widget Configuration.
What im asking is to be notified of the render layer name when it is actually being rendered in batch process, therefore, independent from the main thread and GUI.
This is kind of a very specific geeky question.
Im having a bad time looking for answers as there apparently isnt a proper documentation about the mel scripts options in the render options tabs.

Just to explain a little bit more: the reason why it must be done via a preRenderLayerMel script in the render options tabs is because those are callbacks called by the rendering process at the moment of effectively proceeding the render (be it the layer, in pre/post, each frame in pre/post or the whole rendering process). I dont want to query the RenderSetup or the Legacy Render Layer system is this is the Configuration you have just set up BEFORE  starting to render....

The render layer name (among other layer parameters) must be able to be queried from the render options tabs pre/post RenderLayer Mel since this is a script that is called when starting/finishing to process each render layer! It just must be available somehow.

Either there is a huge lack of documentation about the render options, or it is explained in a very hidden spot. Im guessing the first one!

er...@goodbyekansas.com

unread,
Jul 10, 2019, 6:11:40 PM7/10/19
to Python Programming for Autodesk Maya
Digging this up as I am having a similar problem.

Using editRenderLayerGlobals -q -currentRenderLayer in a preRender script always returns the same layer no matter what -rl flag have been used to start the render.

Juan Cristóbal Quesada

unread,
Jul 11, 2019, 3:15:57 AM7/11/19
to python_in...@googlegroups.com
Hi Erik,
The way i finally handled this is: since i was passing to the render command the list of layers to be rendered and you can know when a new layer has started rendering you can infere the current layer because the order in which they are rendered is the same order that you passed to the render command.

El jue., 11 jul. 2019 a las 0:11, <er...@goodbyekansas.com> escribió:
Digging this up as I am having a similar problem.

Using editRenderLayerGlobals -q -currentRenderLayer in a preRender script always returns the same layer no matter what -rl flag have been used to start the render.

--
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.
Reply all
Reply to author
Forward
0 new messages