this works in viewport but not in render.
import bpy from math import * def frame_handler(scene): z = scene.objects['Lift'].location scene.objects['Text'].data.body = str(floor(z / 4.0) - 2) bpy.app.handlers.frame_change_pre.clear() bpy.app.handlers.frame_change_pre.append(frame_handler)
How to get it working in render? I've read this answer and changed from "bpy.data.objects" to "scene.objects" as already seen in the script. What am I missing? Blender v. 2.81.16
Edit. Tried that depsgraph thing mentioned in comments and changed to frame_change_post:
import bpy from bpy.app.handlers import persistent from math import * @persistent # maybe not relevant but doesn't harm anything? def frame_handler(scene, depsgraph): z = scene.objects['Lift'].evaluated_get(depsgraph).location scene.objects['Text'].data.body = str(floor(z / 4.0) - 2) bpy.app.handlers.frame_change_pre.clear() bpy.app.handlers.frame_change_post.clear() bpy.app.handlers.frame_change_post.append(frame_handler)
Now the Text doesn't show up at all in rendered (but works in viewport).