Skip to content

Instantly share code, notes, and snippets.

@tokejepsen
Last active November 5, 2021 14:56
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 tokejepsen/71e158b3c05718401e2d620fc8e6cc54 to your computer and use it in GitHub Desktop.
Save tokejepsen/71e158b3c05718401e2d620fc8e6cc54 to your computer and use it in GitHub Desktop.
Nuke: Start, middle and end frame of each TimeClip
"""
Select all TimeClips and run code.
Will produce a frame hold with start middle and end of the time clips.
"""
import nuke
frames = []
for node in nuke.selectedNodes():
node["selected"].setValue(False)
if node.Class() != "TimeClip":
continue
first = node["first"].getValue()
last = node["last"].getValue()
duration = (last - first) / 2
frames.append(int(first))
frames.append(int(last))
frames.append(int(duration + first))
frames = sorted(frames)
frame_hold = nuke.createNode("FrameHold")
frame_hold["first_frame"].setAnimated()
for count in range(0, len(frames)):
frame_hold["first_frame"].setValueAt(frames[count], count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment