#  nShakeClone.py
#  Nuke Python Module
#
#  Recreates a shake style "uni-directional" clone
#
#  Created by Jesse Spielman on 8/26/2010
#  jesse@themolecule.net
#
#  Take all selected nodes and create dupliates that are linked via expressions 
#  to the original for all knobs except those an exclusionList...there may be 
#  value in defining different exclusionLists per node class...
#
#  Copyright 2010 The Molecule.
#  http://www.themolecule.net
#  All rights reserved.
#
#  Software is provided "as is," which means no guarantees!

def expressionClone():
	exclusionList = ["xpos","ypos","help","hide_input","note_font_color","onCreate","updateUI","knobChanged","note_font","tile_color","selected","autolabel","process_mask","label","onDestroy","inject","indicators","maskFrom","maskChannelMask","maskChannelInput","Mask","postage_stamp","postage_stamp_frame","disable","maskChannelMask", "panel", "maskFromFlag","name","cached","fringe", "maskChannelInput" , "note_font_size" , "filter", "gl_color","transform"]

	originals = nuke.selectedNodes()
	[ n['selected'].setValue(False) for n in nuke.allNodes() ]
	
	for original in originals:
		original['label'].setValue('Clone Master')
		
		new = nuke.createNode(original.Class())
		
		for i in original.knobs():
			if i not in exclusionList:
				new.knob(i).setExpression(original.name()+"."+original.knob(i).name())
				new['label'].setValue(original.name()+ ' Clone')
		
		new['selected'].setValue(False)	

	[ n['selected'].setValue(True) for n in originals ]
			

# Add a menu / keyboard shortcut for this command
#menu = nuke.menu('Nuke')
#n = menu.addMenu('Molecule Tools')
#n.addCommand( 'Shake Style Clone', 'shakeClone()', "Alt+v")
