Last active
July 4, 2022 19:15
-
-
Save BenMcEwan/cf31474c97c5bc1b5a3e1034050a438f 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
# -------------------------------------------------------------- | |
# 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