Skip to content

Instantly share code, notes, and snippets.

@taikomatsu
Created April 25, 2017 15:08
Show Gist options
  • Save taikomatsu/022cb0a0c679d30a8edddd8e4df3be74 to your computer and use it in GitHub Desktop.
Save taikomatsu/022cb0a0c679d30a8edddd8e4df3be74 to your computer and use it in GitHub Desktop.
Remove expressions from file knob on all Reads in Nuke.
import nuke
import os.path
reads = nuke.allNodes('Read')
err_cnt = 0
for i, r in enumerate(reads):
raw = r.knob('file').getValue()
evaluated = r.knob('file').getEvaluatedValue()
full_path = '{}/{}'.format(os.path.dirname(evaluated), os.path.basename(raw))
try:
r.knob('file').setValue(full_path)
print('[Info] {}:\n"{}"->\n"{}"\n\n'.format(r.name(), raw, full_path))
except Exception, e:
print(e)
print('[Error] Skipp: {}'.format(r.name()))
err_cnt += 1
if err_cnt == 0:
print('# Done all successfully.')
else:
print('# Error has occured. Please check log.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment