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]