I try to rotate and translate objects and then insert a keyframe by calling the function below:
def set_keyframe(frame_no, x, y, rotation_z, object_id):
# change frame
bpy.context.scene.frame_current = frame_no
# select the object
currentObject = bpy.data.objects[object_id]
currentObject.select = True
# translate and insert keyframe
currentObject.location.x = x
currentObject.location.y = y
currentObject.keyframe_insert('location')
I could manage to translate the object, however I couldn't find out how to perform the rotation operation. I am just trying to rotate around z axis. I tried to do it using the object's matrix_world
in order to simultaneously translate and rotate the object, as suggested here and here. However, I couldn't manage it. Any help, which may not necessarily use the matrix_world
, would be appreciated!
P.S. my objects are scaled.