How to get xyz coordinates from f-curve We are doing research on monitor human activities to avoid adverse events. In part of it, we did an experiment in our MoCap lap to detect the human motion to monitor his activities. We have f-curves from that motion. But we need all the xyz coordinates values for that motion for that given time (just say about 2-3 minutes) to do a scientific analysis of the data.

Do anyone have an idea how to get xyz values from f-curves?
This question is similar to this one answered by christopheS.

So in the same principle, I just add some more information.


An object has animation data
This data contains curves
A curve is defined by an 'action type' (which is defined in 'data_path') and an 'array index'
Action type and array index will give about what the curve is. For instance an action type equal to 'location' with an array index of 1 is a curve about the Y location of the object
The curve contains keyframe points. Each as a 'co'(ordinate) vector where co[ 0 ] is the frame and co[ 1 ] the value


Additionally you can ask the curve value using 'value = curve.evaluate( frame )'.

The code here is commented, so please tell if it is enough explanation or not.

import bpy

print( '---------' )

# Action types, in order to filter the wanted curves if needed
actionTypes = ('location','rotation_euler','rotation_quaternion','scale')

# Get the object from which we want the animation data
obj = bpy.data.objects['Cube']

# If it has some animation
if obj.animation_data:
    # Iterates over the wanted curves
    # The data_path gives the action's type
    for curve in [c for c in obj.animation_data.action.fcurves if c.data_path.endswith( actionTypes )]:
        # The array_index give the corresponding X, Y or Z index of the curve
        print( curve.data_path, curve.array_index )
        for key in curve.keyframe_points:
            # The curve's points has a 'co' vector giving the frame and the value
            print( 'frame: ', key.co[0], ' value: ', key.co[1] )
    pass
else:
    print("no data")