Skip to content

Instantly share code, notes, and snippets.

@tokejepsen
Last active May 17, 2018 10:02
Show Gist options
  • Save tokejepsen/370eaea72f247585d5f699638f16fb7a to your computer and use it in GitHub Desktop.
Save tokejepsen/370eaea72f247585d5f699638f16fb7a to your computer and use it in GitHub Desktop.
Nuke Latest Version
"""
Select read nodes to find latest version.
Initial search range for versions are 50 versions up.
"""
import nuke
import nukescripts
nodes = nuke.selectedNodes()
search_range = [0, 5]
valid_paths = []
for node in nodes:
if node.Class() != "Read":
continue
frame = node["frame"].getValue()
node["frame"].setValue("0")
for count in range(search_range[0], search_range[1]):
path = nuke.filename(node, nuke.REPLACE)
if os.path.exists(path):
valid_paths.append([node, node["file"].getValue()])
nukescripts.version_up()
for count in range(search_range[0], search_range[1]):
nukescripts.version_down()
node["frame"].setValue(frame)
for node, path in valid_paths:
node["file"].setValue(path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment