joepal wrote:Not saying this is valid for your situation, but there are other places where bone rotations can be locked.
Aranuvir wrote:Just a little annotation to Joel's post: You could try to switch the transform method, too, from quaternion to some ZXY-Euler.
Thank you very much, Joel and Aranuvir! I didn't know about this panel and it's much more intuitive to turn the eyes there than in the Face Rig panel. With these two hints, I now found a way to turn the eyes in the console. So far, my script looks like this:
- Code: Select all
import bpy
import math
# Gaze directions in degrees of aversion
gazeDir = [-9,-3,-1,0,1,2,9]
# Set eye-bone rotation mode to XYZ Euler
bpy.context.object.pose.bones["eye.L"].rotation_mode = 'XYZ'
bpy.context.object.pose.bones["eye.R"].rotation_mode = 'XYZ'
for i in gazeDir:
# Turn both eyes (converting degrees to radian)
bpy.context.object.pose.bones["eye.L"].rotation_euler[2] = math.radians(gazeDir[i])
bpy.context.object.pose.bones["eye.R"].rotation_euler[2] = math.radians(gazeDir[i])
# Render image
bpy.context.space_data.context = 'RENDER'
# Save image
bpy.ops.image.save_as(save_as_render=True, copy=True, filepath="//test_"+str(gazeDir[i])+".png", relative_path=True, show_multiview=False, use_multiview=False)
The only thing that doesn't seem to work is saving the image (not even as a one-liner in the console), giving back
- Code: Select all
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "C:\Program Files\Blender Foundation\Blender\2.78\scripts\modules\bpy\ops.py", line 189, in __call__
ret = op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.image.save_as.poll() failed, context is incorrect