top of page
Writer's pictureVidhun Ghai

DAG SCALER

If u are a messy comper like me :) , You can try using this small script to quickly scale up your node graph to create more space between your nodes , you can even downscale it as well, not sure why you would want that :p.

There is an option to restore your nodes to their original position as well.





HERE IS THE PYTHON SCRIPT BELOW :



def checkKnobs():


allNodes=nuke.allNodes()


for node in allNodes:

if node.knob("myxy"):

pass


else:

nodeK=nuke.XY_Knob("myxy","position")

node.addKnob(nodeK)


posx=node.knob('xpos').value()


posy=node.knob('ypos').value()


node.knob("myxy").setValue(posx,0)

node.knob("myxy").setValue(posy,1)


def restore():

sel=nuke.allNodes()


for node in sel:

if (node.name())=="SCALE_CONTROL":

pass


else:


posx=node['myxy'].value(0)

posy=node['myxy'].value(1)

node.knob('xpos').setValue(posx)

node.knob('ypos').setValue(posy)



def resize():


node=nuke.toNode('SCALE_CONTROL')

args=node.knob("ScaleValue").value()

allNodes=nuke.allNodes()


for run in allNodes:

posx=run.knob('xpos').value()

posy=run.knob('ypos').value()

newPosx=posx*args

newPosy=posy*args

run.knob('xpos').setValue(newPosx)

run.knob('ypos').setValue(newPosy)



def createMasterControl():


if (nuke.toNode("SCALE_CONTROL")):

sel=nuke.toNode("SCALE_CONTROL")

selPosx=sel.knob('xpos').value()

selPosy=sel.knob('ypos').value()

nuke.zoom(1,[selPosx,selPosy])

nuke.message("This node is already present in the node graph")

else:

checkKnobs()

operator=nuke.createNode("NoOp")

operator['label'].setVisible(False)

operator['note_font'].setVisible(False)

operator['note_font'].setVisible(False)

operator['note_font_size'].setVisible(False)

operator['note_font_color'].setVisible(False)

operator['hide_input'].setVisible(False)

operator['name'].setValue('SCALE_CONTROL')


message="Scaling factor for node graph,value less than 1 will scale down"


operatorSlider=nuke.WH_Knob("ScaleValue", message)

operator.addKnob(operatorSlider)


operator.knob('ScaleValue').setValue(1)

pyKnob=nuke.PyScript_Knob("scaleUp",label="execute",command='resize()')


operator.addKnob(pyKnob)


restoreKnob=nuke.PyScript_Knob("restore",label="restore",command='restore()')


operator.addKnob(restoreKnob)


return operator.knob('ScaleValue').value()



userChoice=createMasterControl()



























10 views0 comments

Recent Posts

See All

Comments


bottom of page