0
$\begingroup$

I have a simple script like this:

import bpy

obj=bpy.data.objects["Cube"]

obj.rotation_euler.x=0.3
obj.location.x=2

bpy.ops.render.render(animation=False, write_still=True)

and an animation where the location changes
so whenever I run the script first the rotation & location changes
but when executing render() the location gets set back to animation value

how do I avoid that? I thought animation=False avoids playing animation and renders as is

$\endgroup$

1 Answer 1

0
$\begingroup$

I found a solution but it's a little hacky,
remove the animation action before rendering and then re-add it

import bpy

obj=bpy.data.objects["Cube"]

# removing Action
temp_action=obj.animation_data.action
obj.animation_data.action=None

# disabling ShapeKey Action
temp_shape_key_action=None
if(obj.data.shape_keys.animation_data):
    temp_shape_key_action=obj.data.shape_keys.animation_data.action
    obj.data.shape_keys.animation_data.action=None

# changes
obj.rotation_euler.x=0.3
obj.location.x=-4

# rendering
bpy.ops.render.render(write_still = True)

## Re adding Actions 
obj.animation_data.action=temp_action
if(temp_shape_key_action):
    obj.data.shape_keys.animation_data.action=temp_shape_key_action
$\endgroup$

You must log in to answer this question.

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