I'm trying to animate the colour and strength properties of an emission shader based on external data using script. I add a cube and give it an emission shader. I can alter the strength property using:


I then try to add a keyframe on the strength property using:


But I can't get the correct data_path. I must be missing something fundamental here. I have quite limited scripting experience in blender.

Code suggestions gratefully received.


1 Answer 1


You need to get a bit closer to what you want to keyframe. It is the socket that keyframes one of it's values, not the material. So you want to tell the input socket to insert a keyframe.

So this slight variation of what you have will work (only over two lines for clarity) -

node = bpy.context.active_object.active_material.node_tree.nodes['Emission']
  • $\begingroup$ This makes sense, I tried a variation of this but wasn't getting the data path correct; seems obvious now! Much appreciated. $\endgroup$
    – user3556
    Commented May 28, 2014 at 14:15

You must log in to answer this question.

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