Render layer selection when rendering via python 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]
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