Hi! I made this script to render a group of objects in sequence and automatically(I have undreds of them), and to make the output file name with the object name. The script looks for all the object in the to_render group, unhide each one and renders it, and the hide it back. Then proceed with the next object. It work well, but when I run the script I can’t stop it until all the objects are rendered. This is not really good for me, so I’m asking for a way to make it stoppable, for example, pressing Esc.
This is the code. Can somebody suggest me a line to add to make it stoppable? Thanks!
import bpy
output_folder = bpy.data.scenes['Scene'].render.filepath #tiene in memoria il percorso neutro
for obj in bpy.data.groups["to_render"].objects:
obj.hide = False
obj.hide_render = False
output = bpy.data.scenes['Scene'].render.filepath + obj.name
bpy.data.scenes['Scene'].render.filepath = output
bpy.ops.render.render(animation = False, write_still = True, use_viewport = False, layer = "RenderLayer", scene="Scene")
bpy.app.handlers.render_complete
bpy.data.groups["to_render"].objects.unlink(obj)
bpy.data.groups["rendered"].objects.link(obj)
obj.hide = True
obj.hide_render = True
bpy.data.scenes['Scene'].render.filepath = output_folder #ripristina il percorso neutro