Advertisement
Guest User

nuke shakeStyleClone v1.3c

a guest
Mar 30th, 2012
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.85 KB | None | 0 0
  1. #  nShakeClone.py
  2. #  Nuke Python Module
  3. #
  4. #  Recreates a shake style "uni-directional" clone
  5. #
  6. #  Created by Jesse Spielman on 8/26/2010
  7. #  jesse@themolecule.net
  8. #
  9. #   version 1.0 on 8/26/2010
  10. #   Initial release
  11. #
  12. #   version 1.1 on 10/25/2010
  13. #   bugfix suggested by Hugh Macdonald to work around cloning array_knobs using setSingleValue()
  14. #
  15. #   version 1.2 on 3/10/2011
  16. #   improvement suggested by Michael Habenicht to handle String Knobs
  17. #
  18. #   version 1.3 on 3/10/2012
  19. #   Added comments / removed some debug statements
  20. #
  21. #   v1.3c
  22. #   hide panel
  23. #   added Hugh's code for renaming
  24. #
  25. #  Take all selected nodes and create dupliates that are linked via expressions
  26. #  to the original for all knobs except those an EXCLUSION_LIST...there may be
  27. #  value in defining different EXCLUSION_LISTs per node class...
  28. #
  29. #  Copyright 2010 The Molecule.
  30. #  http://www.themolecule.net
  31. #  All rights reserved.
  32. #
  33. #  Software is provided "as is," which means no guarantees!
  34.  
  35. import nuke
  36.  
  37. def shakeClone():
  38.     EXCLUSION_LIST = ["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","disable","maskChannelMask", "panel", "maskFromFlag","name","cached","fringe", "maskChannelInput" , "note_font_size" , "filter", "gl_color","transform", "postage_stamp_frame","dope_sheet"]
  39. # other knobs that caused problems before the mods:
  40. # "fbx_load_take_node_names", "file_menu", "file", "fstop", "matrix", "snap_menu", "useMatrix", "world_matrix"'
  41.  
  42.     originals = nuke.selectedNodes()
  43.     [ n['selected'].setValue(False) for n in nuke.allNodes() ]
  44.    
  45.     for original in originals:
  46.         new = nuke.createNode(original.Class(), inpanel=False )
  47.        
  48.         for i in original.knobs():
  49.             if i not in EXCLUSION_LIST:
  50.                                 # Try to set the expression on the knob
  51.                 new.knob(i).setExpression("%s.%s" % (original.name(), original.knob(i).name()))
  52.                                 # This will fail if the knob is an Array Knob...use setSingleValue to compensate
  53.                                 # Thanks Hugh!
  54.                 if isinstance(new.knob(i), nuke.Array_Knob):
  55.                     new.knob(i).setSingleValue(original.knob(i).singleValue())
  56.                                 # This will fail if the knob is a String Knob...use a TCL expression link to compensate
  57.                                 # Thanks Michael!
  58.                 elif isinstance(new.knob(i), nuke.String_Knob):
  59.                     new.knob(i).setValue("[value %s.%s]" % (original.name(), original.knob(i).name()))
  60.                    
  61.         new['selected'].setValue(False)
  62.         newNameFormat = "%s_clone%%d" % original.name()
  63.         i = 1
  64.         while nuke.exists(newNameFormat % i): i += 1
  65.         new.setName(newNameFormat % i)
  66.  
  67.     [ n['selected'].setValue(True) for n in originals ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement