2
$\begingroup$

I am using the "Lighting: Sun Position" add-on that is controlling my Sun light object position, which works and renders correctly on my local host. However for the Sheep-IT farm I apparently have to "bake" this into the Sun light object position and am working a python script:

sun = bpy.data.objects["Sun"]
for iframe in range(bpy.context.scene.frame_start, bpy.context.scene.frame_end + 1, 1):
    bpy.context.scene.frame_current = iframe
    print( bpy.context.scene.sun_pos_properties.time )
    sun.keyframe_insert( data_path="location", frame=iframe )

However the sun_pos_properties.time is always printing the time (for frame #1), even though it is animated, and the inserted keys are also not changing. Can some kind brilliant person give me a hint on how to complete this script?

$\endgroup$
1
$\begingroup$

Simpler than I thought:

sun = bpy.data.objects["Sun"]
sun.select_set(True)
bpy.ops.nla.bake( frame_start=1, frame_end=10, bake_types={'OBJECT'} )
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.