Created
May 3, 2014 06:56
-
-
Save jedypod/c8e52de11e0b4af890ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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