0

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?

Harry McKenzie
  • 10,995
  • 8
  • 23
  • 51

2 Answers2

2

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?

Jag JB
  • 807
  • 4
  • 14
1

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

Harry McKenzie
  • 10,995
  • 8
  • 23
  • 51