I'm trying to create a timeline that graphically shifts across the screen and a text box which displays the currently selected year as the timeline shifts. To accomplish this, I've created a Python script - my first in Blender. It uses the timeline's X-location to calculate what year should be displayed and then updates the text content.
Everything works great in the design space. When I scrub the timeline and play the animation, the year updates as expected. However, when I go to render the animation, the text content is set to whatever value is currently displayed in the timeline of the design space. It doesn't update; it's like it doesn't take the script into account in the final rendered image - but only in the animation. If I render the current frame to an image, it displays accordingly since the timeline accurately reflects the Python update.
Is there a Render setting or a change required in the Python to get this to update in the output FFMPEG animation? Thanks.
import bpy text = bpy.data.objects['YearAD'] lbl = bpy.data.objects['ADBC'] timeline = bpy.data.objects['timeline'] def update(self): loc = timeline.location.x yr = round((-970 - 2020) / (122.71 + 169.293) * (loc + 169.293) + 2020) text.data.body = str(abs(yr)) if yr <= 0: lbl.data.body = 'BC' else: lbl.data.body = 'AD' def register(): bpy.app.handlers.frame_change_pre.append(update) def unregister(): bpy.app.handlers.frame_change_pre.remove(update) register()