예제 #1
0
	def callback():
		k = nuke.thisKnob()
		name, v = k.name(), k.value()
		if not deltas.has_key(name):
			deltas[name] = v
			d = deltas[name]
		else:
			d = diff(v,deltas[name])
			deltas[name] = v
		[n[name].setValue(add(n[name].value(),d)) for n in nuke._allNodes() if n['selected'].value() and n!=control and n.knobs().has_key(name)]
예제 #2
0
def reconnectMissing(indexCmd):
	# On Windows, use Everything (http://www.voidtools.com/).
	# Assumes "es.exe" command line program is in PATH. Note that
	# "es.exe" doesn't work with networked drives.
	# On OS X, use Spotlight.
	errors = [n for n in nuke._allNodes() if n.hasError() and nuke.filename(n) is not None]
	if errors:
		task = nuke.ProgressTask("Missing files!")
		task.setMessage("Reconnecting %i nodes" % len(errors))
		checkLog = False
		for (i,node) in enumerate(errors):
			(dirPath, basename, searchStr) = nuke.actualFilename(node)
			print "Reconnecting %s --> %s" % (node.name(), searchStr)
			results = [l.strip() for l in os.popen("""%s "%s" """ % (indexCmd,searchStr)).readlines()]
			def getNewPath(resultLine):
				(newPath, newBase) = os.path.split(resultLine)
				setPath = re.sub("\\\\","/",newPath) + "/" + basename
				return setPath
			if len(results)==1:
				node['file'].setValue(getNewPath(results[0]))
			elif len(results)>1:
				checkLog = True
				if 'checksums' in node.knobs().keys():
					crc = node['checksums'].value()
					checksums = [hashlib.sha1(open(f).read(10485760)).hexdigest() for f in results]
					if crc in checksums:
						res = results[checksums.index(crc)]
						node['file'].setValue(getNewPath(res))
					else:
						msg = "%s: CRC mismatch with found files" % node.name()
						print "-"*40 + "\n" + msg
						for (i,line) in enumerate(results): print "[%i] %s" % (i,line)
				else:
					node['file'].setValue(getNewPath(results[0]))
					msg = "More than 1 file found for %s:" % node.name()
					print "-"*40 + "\n" + msg
					for (i,line) in enumerate(results): print "[%i] %s" % (i,line)
			else:
				print "Reconnection failed. No files found."
			task.setProgress(int(i*1./len(errors)*100))
		if checkLog:
			msg = "More than 1 file was found for some nodes.\nCheck script editor."
			nuke.executeInMainThread( nuke.message, args=(msg) )
	else:
		pass
예제 #3
0
def checksumOfReadNode(threaded=True):
	readingNodes = [n for n in nuke._allNodes() if not n.hasError() and nuke.filename(n) is not None]
	task = nuke.ProgressTask("")
	task.setMessage("Checking external file dependencies")
	def run():
		for (i,node) in enumerate(readingNodes):
			if 'checksums' not in node.knobs().keys():
				tKnob = nuke.Text_Knob('checksums','checksums')
				tKnob.setVisible(False)
				node.addKnob(tKnob)
			(dirPath, basename, filename) = nuke.actualFilename(node)
			filepath = os.path.join(dirPath, filename)
			if os.path.exists(filepath):
				crc = hashlib.sha1(open(filepath).read(10485760)).hexdigest()
				node['checksums'].setValue(crc)
			task.setProgress(int(i*1./len(readingNodes)*100))
	if threaded: threading.Thread( None, run ).start()
	else: run()
예제 #4
0
def nk_hide_open_panels():
	"""
	Close open panels
	SS Ctrl+h
	"""
	[n.hideControlPanel() for n in nuke._allNodes() if n.shown()]