Difference between revisions of "Nuke Python"
Jump to navigation
Jump to search
(Created page with "=Nuke Python Scripts= === Count selected nodes === <pre> len(nuke.selectedNodes()) </pre>") |
|||
| Line 3: | Line 3: | ||
<pre> | <pre> | ||
len(nuke.selectedNodes()) | len(nuke.selectedNodes()) | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | === Maxwell Render - Check .mxi sequence Sampling levels === | ||
| + | <pre> | ||
| + | //This script comes from the Great Marc Dubrois | ||
| + | |||
| + | def checkMXI_SL(): | ||
| + | '''takes mxi read node and checks its SLs metadata and outputs frames under certain treshold''' | ||
| + | |||
| + | sl_threshold = 18.0 | ||
| + | txt = nuke.getInput('Print frames with SL below:', str(sl_threshold)) | ||
| + | if txt: | ||
| + | sl_threshold = float(txt) | ||
| + | output = '' | ||
| + | |||
| + | task = nuke.ProgressTask("Checking MXI SLs") | ||
| + | task.setMessage("Progress") | ||
| + | |||
| + | for node in nuke.selectedNodes(): | ||
| + | if node.Class() == 'Read': | ||
| + | firstframe = int(node['first'].value()) | ||
| + | #lastframe = firstframe + 10 | ||
| + | lastframe = int(node['last'].value()) | ||
| + | for i in range(firstframe, lastframe): | ||
| + | percentage = int(100.0*(i-firstframe)/(lastframe-firstframe)) | ||
| + | task.setProgress(percentage) | ||
| + | if task.isCancelled(): | ||
| + | break; | ||
| + | |||
| + | sl = node.metadata('SAMPLING_LEVEL',i) | ||
| + | if sl < sl_threshold: | ||
| + | task.setMessage('Frame ['+str(i)+'] SL'+"{0:.1f}".format(sl)) | ||
| + | logline = 'Frame ' + str(i) + ': ' + "{0:.2f}".format(sl) + '\n' | ||
| + | output = output + logline | ||
| + | task.setProgress(100) | ||
| + | del task | ||
| + | |||
| + | p = nuke.Panel('Results') | ||
| + | if output == '': | ||
| + | output = 'All MXI are above or equal to '+str(sl_threshold) | ||
| + | p.addNotepad('Results:',output) | ||
| + | ret = p.show() | ||
| + | |||
| + | checkMXI_SL() | ||
</pre> | </pre> | ||
Revision as of 23:57, 7 June 2019
Nuke Python Scripts
Count selected nodes
len(nuke.selectedNodes())
Maxwell Render - Check .mxi sequence Sampling levels
//This script comes from the Great Marc Dubrois
def checkMXI_SL():
'''takes mxi read node and checks its SLs metadata and outputs frames under certain treshold'''
sl_threshold = 18.0
txt = nuke.getInput('Print frames with SL below:', str(sl_threshold))
if txt:
sl_threshold = float(txt)
output = ''
task = nuke.ProgressTask("Checking MXI SLs")
task.setMessage("Progress")
for node in nuke.selectedNodes():
if node.Class() == 'Read':
firstframe = int(node['first'].value())
#lastframe = firstframe + 10
lastframe = int(node['last'].value())
for i in range(firstframe, lastframe):
percentage = int(100.0*(i-firstframe)/(lastframe-firstframe))
task.setProgress(percentage)
if task.isCancelled():
break;
sl = node.metadata('SAMPLING_LEVEL',i)
if sl < sl_threshold:
task.setMessage('Frame ['+str(i)+'] SL'+"{0:.1f}".format(sl))
logline = 'Frame ' + str(i) + ': ' + "{0:.2f}".format(sl) + '\n'
output = output + logline
task.setProgress(100)
del task
p = nuke.Panel('Results')
if output == '':
output = 'All MXI are above or equal to '+str(sl_threshold)
p.addNotepad('Results:',output)
ret = p.show()
checkMXI_SL()