I've problem Rendering sun rotation animation. Steps to reproduce:

  1. Create the sun object
  2. Set 1st keyframe
    • Select keyframe
    • Rotate sun object using the handle
    • "I" > Select Rotation
  3. Set 10th keyframe (Reproduce same steps found in 2nd point)
  4. Add frame_change_post handler to print sun rotation_euler
  5. Run Render > Render Animation

The result was 11 times (0-10) printed same rotation Euler <Euler (x=-7.9113, y=0.2392, z=-7.1615), order='XYZ'> .But when I move from keyframe to keyframe Euler XYZ positions are updated. Why is that so?

Here is a demo plugin created to replicate the issue:

bl_info = {
"name": "Sun animation using lever",
"author": "karlisup",
"version": (1, 0),
"blender": (2, 80, 0),
import bpy
from bpy.app.handlers import persistent

def sun_handler(scene, depsgraph):
    if "Sun" not in bpy.data.objects:
    sun = bpy.data.objects["Sun"]
    print(scene.frame_current, sun.rotation_euler)

def create_sun():
    bpy.context.view_layer.active_layer_collection = bpy.context.view_layer.layer_collection
    light_data = bpy.data.lights.new(name="Sun", type='SUN')
    light_data.energy = 30
    light_object = bpy.data.objects.new(name="Sun", object_data=light_data)
    light_object.location = (5, 5, 5)
    bpy.context.view_layer.objects.active = light_object

def register():

def unregister():

if __name__ == "__main__":
  • 4
    $\begingroup$ To me, this script is working correctly except that the handler should have 2 arguments: the scene and the depsgraph. To tell it another way, I don't think what is printed is from the function indicated in the question. $\endgroup$
    – lemon
    Commented Feb 23, 2020 at 8:42
  • $\begingroup$ Seen your edit. What I meant was not only about the missing arguments but the hypothesis that all works fine (it works fine when I test it) but these missing arguments or something else make so what is printed is your env is not the rotation of the expected object. $\endgroup$
    – lemon
    Commented Feb 24, 2020 at 11:13
  • $\begingroup$ Thanks, @lemon for the comment. I updated the code regarding handler parameters. I'll try to clarify my question as this doesn't quite solve my confusion. The problem is with 2 views. In one Euler changes sun rotation coordinates, but whenever Animation is Rendered - it doesn't. I tried to illustrate it here: youtu.be/0Q8FsuDrC1k I $\endgroup$
    – karlisup
    Commented Feb 24, 2020 at 11:40
  • $\begingroup$ You say that I should be somehow extracting rotation of an object from the scene (the context)? Sorry, Blender is new to me :) $\endgroup$
    – karlisup
    Commented Feb 24, 2020 at 11:42
  • $\begingroup$ "what is printed is your env is not the rotation of the expected object" This totally makes sense. Could you help me to understand how to get a rotation of the object while I am using "Render Animation" as I couldn't find examples in existing atmosphere plugins? $\endgroup$
    – karlisup
    Commented Feb 24, 2020 at 11:50

2 Answers 2


It seems that during rendering you need to use the depsgraph so that you obtain an evaluated object.

Don't know why this is not useful when just playing the animation.

So add this line:

sun = sun.evaluated_get(depsgraph)

In the complete function:

def sun_handler(scene, depsgraph):
    if "Sun" not in bpy.data.objects:
    sun = bpy.data.objects["Sun"]
    sun = sun.evaluated_get(depsgraph)
    print(scene.frame_current, sun.rotation_euler)

A link to the documentation if needed.

For information, I've asked on blender coders and had an answer by dr.Sybren:

The difference is caused by the render engine using its own dependency graph, which is not marked as 'active'. As a result, it does not copy animated values back from evaluated to original objects.

This behavior is confirmed to be intended.

  • 4
    $\begingroup$ Note that the depsgraph argument for the handler only exists since 2.81. $\endgroup$ Commented Feb 24, 2020 at 12:10
  • $\begingroup$ I tested the demo script and it really worked, awesome! I still got to wrap my head around about "why" and "how" yet. Just let me first test it on the real plugin, just to see if it works there. $\endgroup$
    – karlisup
    Commented Feb 24, 2020 at 12:11
  • 1
    $\begingroup$ Although it introduced another issue that I've to fix, it solved the issue I was tackling for a while. Thank you for your effort! I accepted your answer. $\endgroup$
    – karlisup
    Commented Feb 25, 2020 at 8:35

In sequence-view:

  • click View menu item
  • click Sequence Render animation

This will correctly export an animation with frame_handler


You must log in to answer this question.

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