2
$\begingroup$

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?

$\endgroup$
3
  • $\begingroup$ thank you for that- it's in the fbx format. I've already imported it to Blender $\endgroup$
    – Raca
    Commented Mar 21, 2017 at 11:43
  • $\begingroup$ Suggest you could get the location and rotation vectors directly from the pose bones, rather than from the fcurves. $\endgroup$
    – batFINGER
    Commented Mar 21, 2017 at 12:17
  • $\begingroup$ 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? $\endgroup$
    – Raca
    Commented Mar 23, 2017 at 11:46

1 Answer 1

1
$\begingroup$

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")
$\endgroup$
2
  • $\begingroup$ 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. $\endgroup$
    – user37066
    Commented Mar 19, 2017 at 7:12
  • $\begingroup$ @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... $\endgroup$
    – lemon
    Commented Mar 19, 2017 at 15:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .