Skip to content

Instantly share code, notes, and snippets.

@BenMcEwan
Last active July 4, 2022 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save BenMcEwan/cf31474c97c5bc1b5a3e1034050a438f to your computer and use it in GitHub Desktop.
Save BenMcEwan/cf31474c97c5bc1b5a3e1034050a438f to your computer and use it in GitHub Desktop.
# --------------------------------------------------------------
# operationSwitcher.py
# Version: 2.0.0
# Last Updated: August 23rd, 2018
# Thanks to Falk Hofmann for making improvements!
# --------------------------------------------------------------
# --------------------------------------------------------------
# USAGE:
#
# Shift+S toggles between over/under, mask/stencil, plus/from, etc.
# Add this to menu.py
# --------------------------------------------------------------
# ----- TOGGLE TRACKER AND MERGE OPERATIONS -----------------------
def operationSwitcher():
node = nuke.selectedNode()
merge_ops = {'stencil': 'mask', 'over': 'under', 'from': 'plus', 'out': 'in'}
if node.Class() == "Merge2":
current_op = node['operation'].value()
if current_op in merge_ops.keys():
node['operation'].setValue(merge_ops[node['operation'].value()])
elif current_op in merge_ops.values():
node['operation'].setValue(merge_ops.keys()[merge_ops.values().index(current_op)])
# Add to edit menu
nuke.menu('Nuke').addCommand( 'Edit/Switch Operation', operationSwitcher, "ctrl+shift+s")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment