MagicSwitch

This is a switch that disconnects itself completely, from the input not currently in use

The reason I made this was because I found that working in very large nuke files got faster if you disconnected portions of the node tree. A normal switch doesn’t completely bypass what is upstream, for whatever reason… so the MagicSwitch was created to test that theory. In practice I have found it keeps my large scripts much lighter, while still providing the same benefits as a normal switch node.


Quick Start

How To Use

Step 1: Connect the 0 input to the node you want the 0 input to be

Step 2: Connect the 1 input to the node you want the 1 input to be

Step 3: Change the Witch knob to toggle between inputs and/or disable the node

The MagicSwitch will automatically grab the node name when the input changes, and use it to toggle the inputs depending on the user interactions

How It Compares

After the MagicSwitch is setup, it is functionally the same as normal Switch. You can set the Witch knob value to change the inputs, or disable the node to revert to a value of 0. The only major difference is the MagicSwitch has a limit of 2 inputs, at this time

Copy/Paste & Templates

Because the MagicSwitch stores link names for reconnecting the inputs, when you copy/paste or use a MagicSwitch in a template setup, you have to connect the inputs manually, or via the Connect button, so that the MagicSwitch can find the new node names on creation. If after load the MagicSwitch can’t find one of its inputs, the colour will change to red, to help you easily spot the link issues

Other Features

Magic Backdrops

If you put a MagicSwitch node on a backdrop that’s name starts with “MagicSwitch_” the backdrop will adopt the same colours as the MagicSwitch. This is useful for quickly spotting the state of the MagicSwitch when zoomed out, or when quickly scanning the node graph

Input Labels

To the right of the Link knobs there are custom label inputs. You can use these to give each of the inputs a unique label like “Comp” and “Precomp” to help you easier understand what the node is currently connected to. The label will be shown in the node label, and auto change to match the current input

There is also a general node label at the bottom, which isn’t related to any inputs

Magic Buttons

There are a few handy buttons on the MagicSwitch

Connect: Connects inputs, if they exist. Use this before you copy/paste so it preserves the links after the paste operation, or if you are saving the MagicSwitch in a template file

Set Input: This allows you to batch change all the MagicSwitches in you script

Remove/Add Magic: This allows you to convert MagicSwitches into normal switches, or vise versa

Reset: Removes links and resets the MagicSwitch to default settings

Advanced - Behaviour

Here you can modify how the MagicSwitch behaves

Disconnect Inputs: When disabled remove the auto disconnect input logic, and turn into a normal switch

Use Labels For Input Names: When disabled the custom link labels will not be used as input names

Show Witch Value In Label: When disabled the “Witch” knob value won’t be displayed in the node label

Show Current Input Label In Node Label: When disabled don’t display the link label in the node label

Advanced - Colours

You can use the knobs here to pick what colours the MagicSwitch uses for each input/state

Link 0: The colour to use when the node is set to input 0

Link 1: The colour to use when the node is set to input 1

Link Other: The colour to use when the node is set an input outside of the 0-1 range

Link Missing: The colour to use when the node can’t find a link

Disabled: The colour to use when the node is disabled. Note that when the node is disabled it defaults to input 0, so this is expression linked to that colour by default

Backdrop Dim: The amount to darken the "MagicSwitch_BackdropNode" colour compared to the values set above


Versions History

Below is a list of the version release numbers, and their changes. You can see your current version at the bottom of Info tab of the tool

    • Fixed a bug in nuke 15+ where disabling the MagicSwitch didn’t highlight the 0 input correctly

    • Added logic that remembers the “Witch” value before MagicSwitch is disabled, so it can be recalled when enabled later

    • Added MagicSwitch Backdrop support

    • Added Advanced colour options

    • Added Advanced behaviour options

    • Updated AutoLabel script

    • Added OnCreate script to help keep links when copy/pasting, or loading templates

    • This version doesn’t exist for some reason ¯\_(ツ)_/¯

    • Initial release

That’s it! I hope it helps, and feel free to reach out if you have any more questions!

Previous
Previous

Python Code Snippets

Next
Next

RenderSwitch