# 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?

• thank you for that- it's in the fbx format. I've already imported it to Blender
– Raca
Mar 21, 2017 at 11:43
• Suggest you could get the location and rotation vectors directly from the pose bones, rather than from the fcurves. Mar 21, 2017 at 12:17
• So, how can I print or save all location vectors of the given animation? is it possible me to filter all location vectors(xyz values) for the given animation of the object in a separate file such as excel or notepad?
– Raca
Mar 23, 2017 at 11:46

This question is similar to this one answered by christopheS.

• 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, ' value: ', key.co )
pass
else:
print("no data")

• Thank you for that python codings. I applied it to my problem. I get some output, I think it is a part of xyz coordinates. but I need full of xyz values for the given f-curve. Please note that I am new to python programming. Mar 19, 2017 at 7:12
• @user37066, each curve is dedicate to an axis (so a curve for X, another one for Y, etc.). To combine them all, go through the coordinates of each/one and if no coordinate corresponds for the others, call "evaluate(frame)" on them... Short comment, this is the principle, and the rest is Python coding... Mar 19, 2017 at 15:28