1
$\begingroup$

I have an operator with the following loop, and I would like to be able to stop the render when I press the Edc key.

When the operator goes into the loop the UI freezes until the renders are done, which could be a long time.

             for cam in cameras:
                if not cam.hide_render:
                    bpy.context.scene.camera = cam
                    img_path = os.path.join(output_directory, f"{cam.name}.png")

                    if context.scene.use_multiview_override:
                        bpy.context.scene.render.filepath = img_path
                        bpy.ops.render.render(write_still=True)
                        images.append(Image.open(bpy.context.scene.render.filepath))
                    else:
                        if os.path.exists(img_path):
                            images.append(Image.open(img_path))
                        else:
                            bpy.context.scene.render.filepath = img_path
                            bpy.ops.render.render(write_still=True)
                            images.append(Image.open(bpy.context.scene.render.filepath))
$\endgroup$
4
  • $\begingroup$ blender.stackexchange.com/questions/86372/… $\endgroup$ Aug 16, 2023 at 10:25
  • $\begingroup$ Thank you for the link. I looked at the post. Unlike their issue, mine is not that it takes long but the fact that the Edc key will not cancel the render if the render was called from the console not invoking default. I do not know how to make the Edc key cancel the render :( $\endgroup$ Aug 18, 2023 at 7:13
  • $\begingroup$ I'm not sure but my blind guess is that when you render from the console Blender starts some sub process in the background that doesn't take keyboard input. Key presses are only read by the currently open UI instance $\endgroup$ Aug 18, 2023 at 12:00
  • $\begingroup$ I think your guess is a very good one, cause I cannot even find an operator to cancel the render from console in the API $\endgroup$ Aug 18, 2023 at 23:22

0

You must log in to answer this question.

Browse other questions tagged .