How to keyframe changes to assigned materials in Cycles I'm trying to set-up an animation where each frame renders an object using one of several materials with the whole sequence rendering out all the material variations.  Unfortunately, it doesn't seem possible to keyframe node connection changes in the Node Editor.  I've 12 materials that I need to connect to some more nodes before the material output.  I was thinking I might render this out over 12 frames, each one using a different material node setup.  It's not as simple as an RGB colour change.  This is the code I've tried but it appears to only set the final material for all frames.

mat = nodes.get("mat1")
link = links.new(mat.outputs[0], car.inputs[0])
car.inputs[1].keyframe_insert(data_path="default_value", frame=1)

mat = nodes.get("mat2")
link = links.new(mat.outputs[0], car.inputs[0])
car.inputs[1].keyframe_insert(data_path="default_value", frame=2)


Is there any way I can script this in Python?
It is not possible to keyframe changes to structure (eg adding/removing nodes or links). 

You can achieve the same effect by using mix nodes/mix shaders and keyframe there factor. Or create many different materials and keyframe the material slot.