Created
December 18, 2013 02:51
-
-
Save dbr/8016555 to your computer and use it in GitHub Desktop.
Get all files referenced by a Nuke file knob
This file contains hidden or 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
def _collect_file_knob(node): | |
# disallow locally-cached paths, otherwise evaluating gives localised path | |
if node.knob('cacheLocal'): | |
orig = node['cacheLocal'].value() | |
node['cacheLocal'].setValue('never') | |
# Frame range to evaluate | |
fr = nuke.FrameRange(node['first'].value(), node['last'].value(), 1) | |
# Evaluation context thing, modified later | |
output_context = nuke.OutputContext() | |
files = [] | |
for viewnumber in range(output_context.viewcount()): | |
# Loop over each view | |
# Skip "default" view | |
viewname = output_context.viewname(viewnumber) | |
if viewname not in nuke.views(): | |
continue | |
# Set evaluation context view number | |
output_context.setView(viewnumber) | |
# Evaluate file for current view and frame | |
for framenum in fr: | |
# Loop over each frame | |
output_context.setFrame(framenum) | |
# ..and evaluate the file knob for this view/frame | |
evaluated_filepath = node['file'].getEvaluatedValue(output_context) | |
files.append(evaluated_filepath) | |
# Restore original cacheLocal setting | |
node['cacheLocal'].setValue(orig) | |
return files | |
print _collect_file_knob(nuke.selectedNode()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment