1
$\begingroup$

I've checked out similar questions and I believe that this is a distinct question. I'm attempting to update a text object every frame based on an attribute on another object so essentially I'm just using the code from this answer.

import bpy

scene = bpy.context.scene
obj = scene.objects['Text']

def recalculate_text(scene):
    x = scene.objects['Cube'].location[0]
    obj.data.body = 'Distance in x-direction: {0:.1f} meters'.format(x)

bpy.app.handlers.frame_change_pre.append(recalculate_text)

My problem is that I'm referencing the scene that uses the frame_change_pre handlers from the sequencer as a scene strip. I attempted to refer to objects absolutely (as opposed to via the provided scene object):

import bpy

obj = bpy.data.objects['Text']

def recalculate_text(scene):
    x = bpy.data.objects['Cube'].location[0]
    obj.data.body = 'Distance in x-direction: {0:.1f} meters'.format(x)

bpy.app.handlers.frame_change_pre.append(recalculate_text)

But that hasn't worked either. The numbers just don't animate at all while rendering. (although the frame_change_pre handler works when I scrub around in the scene that has the Text object)

Any ideas about how to get a frame_change_pre handler to work with a scene strip?

$\endgroup$

1 Answer 1

0
$\begingroup$

The resolution to this problem was to use the frame_change_post callback to as described in this answer.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .