This module contains callbacks
This script shows the most simple example of adding a handler.
import bpy
def my_handler(scene):
print("Frame Change", scene.frame_current)
bpy.app.handlers.frame_change_pre.append(my_handler)
By default handlers are freed when loading new files, in some cases you may wan’t the handler stay running across multiple files (when the handler is part of an addon for example).
For this the bpy.app.handlers.persistent decorator needs to be used.
import bpy
from bpy.app.handlers import persistent
@persistent
def load_handler(dummy):
print("Load Handler:", bpy.data.filepath)
bpy.app.handlers.load_post.append(load_handler)
Callback list - on frame change for playback and rendering (after)
Callback list - on frame change for playback and rendering (before)
Callback list - on loading a new blend file (after)
Callback list - on loading a new blend file (before)
Callback list - on cancelling a render job
Callback list - on completion of render job
Callback list - on render (after)
Callback list - on render (before)
Callback list - on printing render statistics
Callback list - on saving a blend file (after)
Callback list - on saving a blend file (before)
Callback list - on updating the scenes data (after)
Callback list - on updating the scenes data (before)
Function decorator for callback functions not to be removed when loading new files