From fde215025eff7f3581435bfdb90fb9d354538d07 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 31 Aug 2011 10:43:22 +0000 Subject: patch [#28218] During-render callback functionality from Jesse Kaukonen (gekko) --- text from the patch. Recently Campbell Barton added callback functionality for Python's usage, but this only includes pre- and post-render callbacks. There are no callbacks for the duration of the render. This patch adds the few lines required for executing a callback while Blender Render is working. The callback resides in the rendering pipeline stats function, so whenever statistics are printed, the callback is executed. This functionality is required if one wants to: 1) Observe what is happening while Blender is rendering via the command line 2) Add custom statistics that Blender prints while the renderer works 3) The user wants to continue executing his Python script without the code halting at bpy.ops.render.render() Personally I'm currently using this for printing out more detailed progress reports at Renderfarm.fi (such as CPU time, time spent rendering, total progress in regards to the entire rendering process). Tested on Windows, Linux and OS X. Example on how to use the callback: def statscall(context): print("Thanks for calling!") bpy.app.handlers.render_stats.append(statscall) bpy.ops.render.render(animation=False, write_still=True) --- source/blender/python/intern/bpy_app_handlers.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/blender/python/intern/bpy_app_handlers.c') diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index 26d9ca76e3f..e7e46160199 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -42,9 +42,10 @@ static PyTypeObject BlenderAppCbType; static PyStructSequence_Field app_cb_info_fields[]= { {(char *)"render_pre", NULL}, {(char *)"render_post", NULL}, - {(char *)"load_pre", NULL}, + {(char *)"render_stats", NULL}, + {(char *)"load_pre", NULL}, {(char *)"load_post", NULL}, - {(char *)"save_pre", NULL}, + {(char *)"save_pre", NULL}, {(char *)"save_post", NULL}, {NULL} }; -- cgit v1.2.3