2
$\begingroup$

Related to this issue. I created a new .blend file for a test case. A moving object Lift is parent to Camera and Text objects.

enter image description here

The lower Text is updated every frame to show the altitude of the Lift. As adviced by user lemon (see the link above) I set up this script:

import bpy

def frame_handler(scene,depsgraph):
    print(depsgraph)
    obj = scene.objects['Lift']
    obj = obj.evaluated_get(depsgraph)
    z = obj.location[2]
    scene.objects['DynamicText'].data.body = 'z = {:06.3f} m'.format(z)

bpy.app.handlers.frame_change_post.clear()
bpy.app.handlers.frame_change_post.append(frame_handler)

The idea is that camera films both the scenery and the altitude text. It works fine in viewport:

enter image description here

However, the render result is strange. The Text moves vertically in an unintentional way:

enter image description here

Blender file:

Edit. Blender version is 2.81.16

$\endgroup$
5
  • $\begingroup$ It seems that accessing some_obj.data somehow causes it. Looks like it breaks the parenting with Lift (although, some_obj.parent keeps printing 'Lift'). (ie, scene.objects['StaticText'].data.extrude = .01 breaks it) $\endgroup$
    – thibsert
    Commented Feb 27, 2020 at 13:43
  • 1
    $\begingroup$ As mentioned prior, this appears buggy at the moment. (Treading on off-topic) And repeating: Meanwhile If you wish to render animation, render as single image in a loop changing frames. This way you will get a render that matches viewport display. $\endgroup$
    – batFINGER
    Commented Feb 27, 2020 at 13:58
  • 1
    $\begingroup$ A work around: def frame_handler(scene,depsgraph): obj = scene.objects['Lift'] obj = obj.evaluated_get(depsgraph) z = obj.location[2] altitude = scene.objects['DynamicText'] text_z = altitude.location[2] altitude.data.body = 'z = {:06.3f} m'.format(z) altitude.location[2] = text_z $\endgroup$
    – lemon
    Commented Feb 27, 2020 at 14:51
  • $\begingroup$ Nice workaround @lemon. It's simple and does the trick but I certainly wouldn't have come up with it. I think it's a valid solution. $\endgroup$ Commented Feb 27, 2020 at 16:52
  • $\begingroup$ @user3202179 thanks. Won't write an answer about it, as said by batFinger there are problably some buggy aspects in this version and so an answer is not valuable except for make it working for you. $\endgroup$
    – lemon
    Commented Feb 27, 2020 at 16:55

0

You must log in to answer this question.

Browse other questions tagged .