Maniphest T75364

Frame Change App Handler does not update animated data when rendering
Closed, Archived

Assigned To
Philipp Oeser (lichtwerk)
Authored By
Sam Brubaker (rocketman)
Apr 4 2020, 1:26 AM
Tags
  • BF Blender
  • Add-ons (BF-Blender)
Subscribers
Philipp Oeser (lichtwerk)
Sam Brubaker (rocketman)

Description

Version: 2.82a (Linux 64-bit)
This is my first python-related bug report so I apologize if my code is actually bad.

How to reproduce:

  1. open blender in the console
  2. open the attached file
  3. run the script
  4. scrub/change frames and observe the console output (it works correctly).
  5. now render an animation and observe the console output

The app handler continues to run and print the correct scene number, but does not update the values which are animated. This makes no sense.

import bpy

cube = bpy.data.objects['Cube']

def frame_change(dummy):
    print("The current frame is " + str(bpy.context.scene.frame_current))
    print("Cube's X location is " + str(cube.location.x))
    print("Cube's custom property is " + str(cube['prop']))
    
bpy.app.handlers.frame_change_post.append(frame_change)

Event Timeline

Sam Brubaker (rocketman) created this task.Apr 4 2020, 1:26 AM
Sam Brubaker (rocketman) added a project: Add-ons (BF-Blender).Apr 4 2020, 1:30 AM

I should also add that this issue does not only affect console output. If a script affects scene data based on animated values, it will work in viewport playback but not when rendering.

Sam Brubaker (rocketman) added a comment.Apr 4 2020, 5:34 AM

The issue also appears to affect multiple app handlers? Not just frame_change_post but any handler which is called between rendered frames.

Ankit Meel (ankitm) updated the task description.Apr 5 2020, 12:45 PM
Philipp Oeser (lichtwerk) closed this task as Archived.Apr 5 2020, 1:09 PM
Philipp Oeser (lichtwerk) claimed this task.
Philipp Oeser (lichtwerk) added a subscriber: Philipp Oeser (lichtwerk).

Have a look at T71234: Custom property doesnt update when rendering animation also.
Or here (under Handlers): https://wiki.blender.org/wiki/Reference/Release_Notes/2.81/Python_API

Basically it boils down to having to do something like this instead:

import bpy

cube = bpy.data.objects['Cube']

def frame_change(scene, depsgraph):

    # access evaluated objects prop [these are updated fine in frame_change_post]
    cube_eval = cube.evaluated_get(depsgraph)
    print("Cube's X location is " + str(cube_eval.location.x))
    print("Cube's custom property is " + str(cube_eval['prop']))

bpy.app.handlers.frame_change_post.append(frame_change)

Think we have to close this (feel free though to comment again if issues persist...)