This code lets you scale up and down the space between the nodes you have selected on your Node Tree. I made this code while training and learning Python, and I find it super useful when I need to create room for new nodes. I have them set on ctrl++ and ctrl+- for the small scale, and crtl+shift++ and ctrl+shift+- for the big one.

Expand Scale Nodes
import nuke
def scaleNodes():
nodes = nuke.selectedNodes()
amount = len(nodes)
# Do nothing if no nodes were selected
if amount == 0: return
# Sum all the X values
allX = sum([n.xpos()+n.screenWidth()/2 for n in nodes])
#Sum all the Y values
allY = sum([n.ypos()+n.screenHeight()/2 for n in nodes])
# Center of selected nodes
centreX = allX/amount
centreY = allY/amount
# Return values to use outside this function
return centreX, centreY
def increase2():
# Set values with scaleNodes() function
centreX, centreY = scaleNodes()
for n in nuke.selectedNodes():
n.setXpos(centreX + (n.xpos() - centreX) * 2)
n.setYpos(centreY + (n.ypos() - centreY) * 2)
def increase8():
# Set values with scaleNodes() function
centreX, centreY = scaleNodes()
for n in nuke.selectedNodes():
n.setXpos(centreX + (n.xpos() - centreX) * 8)
n.setYpos(centreY + (n.ypos() - centreY) * 8)
def decrease2():
# Set values with scaleNodes() function
centreX, centreY = scaleNodes()
for n in nuke.selectedNodes():
n.setXpos(centreX + (n.xpos() - centreX) / 2)
n.setYpos(centreY + (n.ypos() - centreY) / 2)
def decrease8():
# Set values with scaleNodes() function
centreX, centreY = scaleNodes()
for n in nuke.selectedNodes():
n.setXpos(centreX + (n.xpos() - centreX) / 8)
n.setYpos(centreY + (n.ypos() - centreY) / 8)