Hi guys, i’m stuck here, i’m trying to evaluate a newly created FCurve to get the current value of associated property, and keep getting “0”. Here’s an example working code with scale:
import bpy
# getting the object
obj = bpy.context.object
# the active object have action but no scale fcurve
# let's create it for x axis
fc = obj.animation_data.action.fcurves.new("scale", index=0)
# evaluate the current frame
value = fc.evaluate(bpy.context.scene.frame_current)
# print the result
print("value is %f" % value)
This returns “0”, but the active object is “1” in x scale
(can be run from console with selected object with action and no scale keyframe to test)
I don’t really know how to get this “1” value programatically with object and data_path only.
The getattr()
method could work, but i’m also using this code on pose bones, with these kinds of datapath : 'pose.bones["Bone"].location[0]'
and this doesn’t seem to work with getattr()
Any clue out there ? thanks in advance guys ! cheers !