I am adding a bunch of properties to cameras with my add-on. To support animation during renders, I add a frame_change_post handler like this:
import bpy from bpy.app.handlers import persistent from .camera import PhotographerCameraSettings @persistent def update_render_camera(self,depsgraph): camera_ob = bpy.context.scene.camera camera_ob_eval = camera_ob.evaluated_get(depsgraph) # Dictionary of Photographer Camera properties for key in PhotographerCameraSettings.__annotations__.keys(): try: key_eval = camera_ob_eval.data.photographer[key] camera_ob.data.photographer[key] = key_eval except KeyError: # Properties that haven't been changed will return a KeyError pass def register(): bpy.app.handlers.frame_change_post.clear() bpy.app.handlers.frame_change_post.append(update_render_camera)
It works fine, except for the first frame of the render if the current frame is different.
For instance, if I render from frame 1 to 10, and in the viewport I am looking at frame 5, then when rendering the animation (CTRL+F12), frame 1 will use camera property values of frame 5. Frame 2 gets updated properly and the renders continues fine.
It seems that the frame_change_post doesn't get triggered when moving to the first frame. Is there a way to fix it?