top of page

FAST CONNECTIONS

  • jnietomonco
  • Feb 9, 2023
  • 1 min read

This code is a little step beyond Nuke's input and output connection hotkey. It does the same, but with several nodes at the same time.


ree

It can connect the inputs of the nodes you have selected to the last node of your selection. I always mentally think "connect these, here" when I do the selection to not forget the correct order. If a node has several inputs this code will connect the next available one (for example, if B is connected in a Merge, it will connect A to the last node you selected). The hotkey I have set for this tool is the same as the native Nuke one: y.


ree

It can also connect the output of a node to another one. Same as with the input, the order of selection matters (remember: "connect this, here"!). The hotkey I use for this one is u.


ree

You can also connect the mask input of one or several nodes at the same time using the same selection order as I mentioned above. I use the hotkey shift+y for this one.

Expand Fast Connections

import nuke

def connectAllNodesInput():
    try:
        selNodes = []
        for i in nuke.selectedNodes():
            name = i['name'].getValue()
            selNodes.append(name)
        connectTo = selNodes[0]
        selNodes.remove(connectTo)
        for node in nuke.allNodes():
            node['selected'].setValue(False)
        for i in selNodes:
            node = nuke.toNode(str(i))
            node['selected'].setValue(True)
            optionalInputs = node.optionalInput()
            connectedInput = node.inputs()
            if optionalInputs != 0:
                if optionalInputs == 1:
                    node.setInput(0, nuke.toNode(str(connectTo)))
                else:
                    if connectedInput == 0:
                          node.setInput(0, nuke.toNode(str(connectTo)))
                    elif connectedInput < optionalInputs:
                        node.setInput(connectedInput, nuke.toNode(str(connectTo)))
                    else:
                          node.setInput(0, nuke.toNode(str(connectTo)))
    except IndexError:
        pass	

def connectAllNodesOutput():
    try:
        selNodes = []
        for i in nuke.selectedNodes():
            name = i['name'].getValue()
            selNodes.append(name)
        connectTo = selNodes[-1]
        selNodes.remove(connectTo)
        for node in nuke.allNodes():
            node['selected'].setValue(False)
        for i in selNodes:
            node = nuke.toNode(str(i))
            node['selected'].setValue(True)
            optionalInputs = node.optionalInput()
            connectedInput = node.inputs()
            if optionalInputs != 0:
                if optionalInputs == 1:
                    node.setInput(0, nuke.toNode(str(connectTo)))
                else:
                    if connectedInput == 0:
                          node.setInput(0, nuke.toNode(str(connectTo)))
                    elif connectedInput < optionalInputs:
                        node.setInput(connectedInput, nuke.toNode(str(connectTo)))
                    else:
                          node.setInput(0, nuke.toNode(str(connectTo)))
    except IndexError:
        pass

def connectMaskInput():
    try:
        selNodes = []
        for i in nuke.selectedNodes():
            name = i['name'].getValue()
            selNodes.append(name)
        connectTo = selNodes[0]
        selNodes.remove(connectTo)
        for node in nuke.allNodes():
            node['selected'].setValue(False)
        for i in selNodes:
            node = nuke.toNode(str(i))
            node['selected'].setValue(True)
            optionalInputs = node.optionalInput()
            if node.maxInputs() > optionalInputs:
                node.setInput(optionalInputs, nuke.toNode(str(connectTo)))
            elif node.Class() == 'Keymix':
		node.setInput(2, nuke.toNode(str(connectTo)))
    except IndexError:
        pass

Javier Nieto Moncó © 2025

  • linkedin
  • vimeo
  • generic-social-link
bottom of page