roto shape life time based on keyframes
One of my friend requested to automate roto shapes lifetime based on the key frame. We use multiple way to set roto shapes lifetime. Some artists uses lifetime tab in roto node, Some simply move the roto shape out of the working resolution. Some guys are using 'multiply' node to achieve this. Some artists animating 'visible' knob in roto node. The way of doing this will differ from artist to artist. How to make this organised ?.
Here is the idea: lifetimeRoto.py
Most of us using nuke roto node lifetime tab set the lifetime based on the frame range.
Some artists using mouse click option in curve window in roto node.
In both way we need to feed the frame range either we need to choose to-end or to start. Doing this is not time consuming task for compers. But for roto & clean-up artist ?
lifetimeRoto.py automatically sets the selected rotoshapes lifetime based on the shapes key frame's. This code get the selected shapes keyframe value ( example: 10, 20, 30) and apply min and max to lifetime start and end respectively. After i run this code my roto shape lifetime set to 10 - 30 automatically by single click or short-key.
I have assigned 'shift+L' as short-cut. Select your roto shape and make sure you have selected the roto node. Run this shortcut, Boooommmm. Your roto shape lifetime sets based on the keyframe.
I hope this will helpful. Feature request and bug reports are welcome.
menuBar = nuke.menu("Nuke")
menuBar.addCommand('Edit/Node/lifetimeRoto', 'lifetimeRoto.setRotoLifeTime()', 'shift+l')
Created on 07-april-2016
mail - firstname.lastname@example.org
### to set selected roto shapes lifetime based on the min max keyframes value.
### get selected node
selNode = None
selNode = nuke.selectedNode()
except ValueError: # no node selected
if selNode == None:
nuke.message('make sure your roto node selected')
### find selected roto shapes keyframes
if selNode.Class() == 'Roto':
for selShape in selNode['curves'].getSelected():
keyFrame = selShape.center.getControlPointKeyTimes()
keyFrames = [int(i) for i in keyFrame]
low = (min(keyFrames))
high = (max(keyFrames))
### applying min max keyframe to per shape lifetime