gp_render/OP_render_scenes.py

51 lines
1.4 KiB
Python

import bpy
from . import fn
from time import time
class GPEXP_OT_render_all_scenes(bpy.types.Operator):
bl_idname = "gp.render_all_scenes"
bl_label = "Render all scenes"
bl_description = "Render all scene except Render"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
return True
def execute(self, context):
start = time()
ct = 0
for scn in bpy.data.scenes:
if scn.name == 'Scene':
continue
if not scn.use_nodes:
continue
outfiles = [n for n in scn.node_tree.nodes if n.type == 'OUTPUT_FILE']
if not outfiles:
print(f'\n -!-> Skip {scn.name}, No output files')
continue
if all(x.mute for x in outfiles):
print(f'\n -!-> Skip {scn.name}, All output file are muted')
continue
print(f'\n --> Rendering {scn.name}')
# bpy.context.window.scene = scn
bpy.ops.render.render(animation=True, scene=scn.name)
ct += 1
print(f'\nDone. {ct} scenes rendered in {time()-start:.2f}s')
return {"FINISHED"}
classes=(
GPEXP_OT_render_all_scenes,
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)