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]
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$