Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedypod/c8e52de11e0b4af890ba to your computer and use it in GitHub Desktop.
Save jedypod/c8e52de11e0b4af890ba to your computer and use it in GitHub Desktop.
# Time offset start and end of all rotoshapes
import nuke.rotopaint as rp, _curvelib as cl
# Amount of frames to offset
time_offset = -200
t = nuke.frame()
# Get all Roto or RotoPaint nodes and loop through them
roto_nodes = [n for n in nuke.allNodes() if 'Roto' in n.Class()]
for roto_node in roto_nodes:
curves_knob = roto_node["curves"]
root_layer = curves_knob.rootLayer
for e in root_layer:
if isinstance(e, rp.Shape):
print e.name
lifetime_type = e.getAttributes().getCurve('ltt')
range_from = e.getAttributes().getCurve('ltn')
range_to = e.getAttributes().getCurve('ltm')
for attr in [range_from, range_to]:
# Skip shapes that have default values for start and end?
# if lifetime_type.isDefault():
# print "skipping", e.name, "of", roto_node.name()
# continue
attr_val = attr.evaluate(t)
new_attr_val = attr_val + time_offset
attr.addKey(t, new_attr_val)
attr.removeAllKeys()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment