I'm working on a project which requires me to export all keyframes for 1 object (the camera) in a "generated" state, meaning all the control points as well as all the keyframes generated by the interpolation.
I'm not too familiar with python, and this is my first time using the blender API. Is there any way to do this?
Code so far:
import bpy import mathutils action = bpy.data.objects['Camera'].animation_data.action for curve in action.fcurves: for i in range(len(curve.keyframe_points)): point = curve.keyframe_points[i] print(mathutils.geometry.interpolate_bezier(point.co, point.handle_left, point.handle_right, point.co, 100)) # I know the second knot probably shouldn't be point.co here, but I don't know what to make it.
This has the drawback of
point.co only being a Vec2, so it only has x and y, and it doesn't account for whatever the set interpolation type is (I could only find the bezier func). I might be thinking through things wrongly though.'
EDIT: New code, although a bit hacky, is better. It seems to provide what I need
import bpy import mathutils scn = bpy.context.scene obj = bpy.data.objects['Camera'] action = obj.animation_data.action for frame in range(scn.frame_start, scn.frame_end): bpy.context.scene.frame_set(frame) print(obj.location) print(obj.rotation_euler)