0
$\begingroup$

I'm working on a script that renders certain render layers defined in the operator. The script is supposed to make a list of currently enabled render layers, disable all of them, and then enable the layers specified in the operator, render, and then revert the enabled layers to what they were at the start. But, when I run it, the render is always of the layers enabled at the start. However, if I remove the INVOKE_DEFAULT argument from the render command, it works properly. But then it doesn't show the render progress.

What is going on? Is there a better way to do this?

Here is the relevant code snippet:

startlayers = []
enabled_list = [*desired layers*]

for x in bpy.context.scene.render.layers:
    startlayers.append(x.use)
    x.use = False

for x in enabled_list:
    bpy.context.scene.render.layers[x].use = True

bpy.ops.render.render('INVOKE_DEFAULT',scene="Cycles")

for x in range(len(startlayers)):
    bpy.context.scene.render.layers[x].use = startlayers[x]  
$\endgroup$
3
  • $\begingroup$ If you can, use the compositor. By passing INVOKE_DEFAULT the operator is only called one time... One workaround is setting up a modal operator along with some crazy handlers: blender.stackexchange.com/a/71830/31447 However, that's error prone as hell if you don't know what you are doing. $\endgroup$
    – brockmann
    Jul 25, 2018 at 10:03
  • $\begingroup$ I run into problems with the compositor too. If I use the command shown in the compositor render layer nodes, then I get no render progress unless I use INVOKE_DEFAULT, but then it can only render 1 layer at a time. Asking about that here: blender.stackexchange.com/questions/114697/… $\endgroup$
    – Ascalon
    Jul 25, 2018 at 18:12
  • $\begingroup$ IMO that's a waste of time, there is no good solution and not even a good approach atm... $\endgroup$
    – brockmann
    Jul 26, 2018 at 14:03

1 Answer 1

0
$\begingroup$

maybe this helps?

creating more than 20 render layers and connect them to different scenes

I would have posted it as a comment but..

My impression is that you are mixing layers and render layers which are different things.

For each scene you can only have one render layer, correct me if I'm wrong

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .