Dealing with animation values with Python in Nuke is way more confusing than dealing with other values in Nuke. There are a few useful pages out there with lots of information, like the Foundry developers guide, or this guide from Nathan Rusch on Nukepedia. But when a friend asked me if I knew how to get a list of frames that had keyframes on for a particular knob I couldn’t figure out the answer from either of those, so I did a little more searching and found this old forum post from way back in 2011. In this post Pete O’Connell had already figured out the code I needed to get a list of keyframes from a knob. I simplified it a little and changed to work with Multiply node with an animated ‘value’ slider.
n = nuke.selectedNode()
keyframes = []
k = n['value'].animations()[0]
for i in range (len(k.keys())):
keyframes.append(k.keys()[i].x)
print (keyframes)
Latest Comments