# Animation nodes: bake Cycles Material Output to keyframes - possible?

In an older Question I found an answer, what is possible to bake with AN. One in the list was: Cycles Matrial Output (2 Years ago)

I’ve a Plane with Emission-Node as Material, which changes Color and Strength randomly over time.

When I try to Set Keyframes, there is a problem (I believe):

In Set Keyframes-Node you need an object for reference to the data-path (custom-channel), but the material-datapath is not linked to a specific object (bpy.data.materials["feuerlicht"].node_tree.nodes["Emission"].inputs[1].default_value).

Set Keyframes node tells me

Could not set keyframe

And when I look to python code, it seems, that I need an object for keyframe-setting:

obj.keyframe_insert('location', frame=1)

Or, as I found:

material.node_tree.keyframe_insert(datapath, frame=1)

But the material is not a separate object I can choose in then set keyframe-node, or?

I changed from Area-light to this plane-emission-thing to get it baked, I thought.

Is it possible to get Cycles-Material-changes baked to keyframes in AN?

• Hi and welcome! Please add the link to the post you've found to your question. Also I recommend take the tour to learn about how this site works: blender.stackexchange.com/tour Dec 10, 2020 at 18:38
• Hi, thank you. I've edited the post with the link. Dec 11, 2020 at 12:15
• so, I think there does not exist a node for this. I made a quick and dirty script for this: Dec 13, 2020 at 9:29

After further search I think there is no node for this. Now I did it with a quick an dirty script-node:

    # inputs:
# Enable = boolean
# SetKeyframes = boolean
# RemoveUnwanted = boolean
# MaterialName = text
# pframe = integer

import bpy

mat = None

if Enable:
for tmat in bpy.data.materials:
if tmat.name == MaterialName:
mat = tmat
if mat != None:
print ('material found')
emitStr = mat.node_tree.nodes['Emission'].inputs[1]
if RemoveUnwanted:
try:
emitStr.keyframe_delete( 'default_value', frame=pframe)
except:
None
if SetKeyframes:
emitStr.keyframe_insert( 'default_value', frame=pframe)

else: