Getting object that fcurve belongs to

I’m trying to write an exporter for my custom model format for a game engine I’m building. I already managed to export materials, models, and skeletons, but I want to be able to export animations also. The engine has a system to support object keyframes as well, so I’d like to be able to export those too. What I’m having trouble with right now though is figuring out what type of keyframe I’m dealing with, and what object it animates. Right now I’m iterating through each action in the bpy.data.actions collection and then iterating over the fcurves for that action to get the data.

for fcurve in action.fcurves:
		for keyframePoint in fcurve.keyframe_points:

How can I figure out what object the fcurve animates? And also, how can I determine if what kind of keyframe/fcurve it is (position, rotation, scale, etc)?

Object.animation_data.action, but test for animation_data and action not being None first!

That will only give me the active action on the object though. I’m planning to export actions as seperate animations. The Object class has NLA layers, but the NLA is way overkill for game animations. Is my only option to use the NLA and export each track as a seperate animation? That way I have however many actions that I just organize in the NLA and export those?

Only a single action can be associated with an object, all other actions are accessible via bpy.data.actions and there is nothing that indicates if they belong to a certain object or not. In fact, you can use any action for any object.

F-Curve data_paths give a little insight what kind of action you are looking at (pose.bones[…] -> armature action).

Okay. so I guess I may just want to use timeline markers to separate animation sequences then.