Skip to content

Instantly share code, notes, and snippets.

@BenMcEwan
Last active May 9, 2018 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenMcEwan/210dc68a64be5d36896c3de6f577b7d0 to your computer and use it in GitHub Desktop.
Save BenMcEwan/210dc68a64be5d36896c3de6f577b7d0 to your computer and use it in GitHub Desktop.
# --------------------------------------------------------------
# swapInOut.py
# Version: 1.0.0
# Last Updated: January 11th, 2018
# --------------------------------------------------------------
# --------------------------------------------------------------
# USAGE:
#
# Find all in/out (merge) nodes and change them to mask/stencil (flipping the A and B inputs to work correctly).
# --------------------------------------------------------------
import nuke
import nukescripts
def swapInOut():
n = nuke.allNodes()
for i in n:
if i.Class() == 'Merge2':
if i['operation'].value() == 'in':
i['operation'].setValue('mask')
nukescripts.swapAB(i)
elif i['operation'].value() == 'out':
i['operation'].setValue('stencil')
nukescripts.swapAB(i)
# Add the following to menu.py
import swapInOut
utilitiesMenu = nuke.menu('Nuke').addMenu('Utilities')
utilitiesMenu.addCommand('Script Cleanup/Convert In+Out to Mask+Stencil', 'swapInOut.swapInOut()')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment