0
$\begingroup$

I tried to set the camera rotation like this:

camera = bpy.data.objects['Camera']
camera.rotation_mode = 'XYZ'
camera.rotation_euler = [1.1117, 0, 0.762]

The values are changed in Blender, but they are in a different color, and the rotation does not appear while rendering.

enter image description here

But after a mouse click on the changed rotation values, the rotation does appear after rendering... why? Why is it not set in Blender? Is there another way to set the rotation?

$\endgroup$

2 Answers 2

2
$\begingroup$

It seems you are using keyframes. The changing colors indicate that you modified something but didn't re-save the keyframe.

Once the rotation is done, add an "Insert keyframe" step for the rotation (or any property you're storing at that keyframe, e.g. Rotation+Location) to have it applied during render.

See here: How to use Keyframes and the Python API programmatically?

$\endgroup$
2
  • 1
    $\begingroup$ Thank you! Now it works perfectly $\endgroup$ Sep 2 at 16:04
  • $\begingroup$ Glad it worked! Can you accept the solution then so the topic appear as resolved? $\endgroup$
    – Jag JB
    Sep 2 at 16:08
1
$\begingroup$

As @Jag JB has mentioned, you have keyframes on the camera as you can see with the brownish color. It turns orange color temporarily when you change the value manually or change it via script, but it will not be retained when you render something or when you change the frame, unless you explicitly replace the keyframe by right clicking Insert/Replace Keyframe or Insert/Replace Single Keyframe or press I while hovering over the orange field.

The reason it works when you manually transform the camera is because you have Auto Keying toggled on which automatically inserts or replaces the keyframe for every transform on an object or camera. You can turn off Auto Keying if you don't want that behavior.

enter image description here

$\endgroup$

You must log in to answer this question.

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