Using Blender 2.90alpha, I already have some fancy python code to set some keyframes on an object + data_path from my external data source. It creates obj.animation_data.action then calls obj.animation_data.action.fcurves.new(path, index) for each channel, and then inserts points into the fcurves. That works fine for objects. I'd like to do the same for shader nodes; but the examples I've seen all use a different method:

shader_node.inputs[1].default_value = 1
shader_node.inputs[1].keyframe_insert("default_value", frame=10)

and then apparently you can get the fcurve afterward using something like this (?)

action = material.node_tree.animation_data.action
data_path = 'nodes["my shader node"].inputs[1].default_value' # rooted at "node_tree" apparently
fc = action.fcurves.find(data_path)
# ... do things with fc
# apparently the fcurve is actually stored in mat.node_tree.animation_data.action.fcurves

but I'd prefer, if possible, to just create the fcurves directly with their data paths. I haven't seen any examples doing it that way and wonder if it's possible for shader nodes (before I dive into it). And if so, how can I make sure I get those data paths right -- is there any API to get the data path for a value?



Browse other questions tagged .