Sun object not moving when Rendering Animation I've problem Rendering sun rotation animation. Steps to reproduce:


Create the sun object
Set 1st keyframe


Select keyframe
Rotate sun object using the handle
"I" > Select Rotation

Set 10th keyframe (Reproduce same steps found in 2nd point) 
Add frame_change_post handler to print sun rotation_euler
Run Render > Render Animation


The result was 11 times (0-10) printed same rotation Euler
&lt;Euler (x=-7.9113, y=0.2392, z=-7.1615), order='XYZ'&gt;  .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

@persistent
def sun_handler(scene, depsgraph):
    if "Sun" not in bpy.data.objects:
        create_sun()
    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.collection.objects.link(light_object)
    bpy.context.view_layer.objects.active = light_object

def register():
    bpy.app.handlers.frame_change_post.append(sun_handler)

def unregister():
    bpy.app.handlers.frame_change_post.remove(sun_handler)

if __name__ == "__main__":
    register()
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:
@persistent
def sun_handler(scene, depsgraph):
    if &quot;Sun&quot; not in bpy.data.objects:
        create_sun()
    sun = bpy.data.objects[&quot;Sun&quot;]
    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.