Created
July 20, 2021 18:09
-
-
Save heavyimage/8f4a009a79cf23c4c2e5de5dd395bdb4 to your computer and use it in GitHub Desktop.
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
# nShakeClone.py | |
# | |
# Recreates a shake style "uni-directional" clone | |
# | |
# Created by Jesse Spielman on 8/26/2010 | |
def shakeClone(): | |
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"] | |
originals = nuke.selectedNodes() | |
[ n['selected'].setValue(False) for n in nuke.allNodes() ] | |
for original in originals: | |
new = nuke.createNode(original.Class()) | |
for i in original.knobs(): | |
if i not in EXCLUSION_LIST: | |
# Try to set the expression on the knob | |
new.knob(i).setExpression("%s.%s" % ( | |
original.name(), original.knob(i).name())) | |
# This will fail if the knob is an Array Knob... | |
# use setSingleValue to compensate! | |
# Thanks Hugh! | |
if isinstance(new.knob(i), nuke.Array_Knob): | |
new.knob(i).setSingleValue(original.knob(i).singleValue()) | |
# This will fail if the knob is a String Knob... | |
# use a TCL expression link to compensate! | |
# Thanks Michael! | |
elif isinstance(new.knob(i), nuke.String_Knob): | |
new.knob(i).setValue("[value %s.%s]" % ( | |
original.name(), original.knob(i).name())) | |
new['selected'].setValue(False) | |
[ n['selected'].setValue(True) for n in originals ] | |
# Add a menu / keyboard shortcut for this command | |
menu = nuke.menu('Nuke') | |
molTools = menu.addMenu('heavyimage') | |
molTools.addCommand( 'Shake Style Clone', 'shakeClone()', "Alt+v") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment