123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- # GUIFarm by Andreas Gebauer
-
- # Lets you disable nodes in the gui and globally turn them on and off for previewing without using expression links. Tested in Nuke 9 and 10.
-
- # 1. Select node and press SHIFT + D.
- # 2. Set values in the 'gui' and 'farm' fields. By default node is True in gui and False on farm.
- # 3. Globally turn them on and off in the top GUIFarm menu with "Toggle preview"
-
- # GUIFarm Menu:
- # Disable all: Removes expressions from all GUIFarm affected nodes and sets disable knob to False.
- # Enable all: Enables all GUIFarm affected nodes and sets $gui expression.
-
- # You can use this on other boolean knobs as well but I haven' really tested it.
-
-
-
-
- import nuke
-
-
- guiFarmPreview = False
-
-
-
- def build():
-
-
-
- disableThis = 'nuke.thisNode()[nuke.thisNode()["knobName2"].value()].clearAnimated()\nnuke.thisNode()["GUIFarmEnabled"].setValue(False)\nnuke.thisNode()[nuke.thisNode()["knobName2"].value()].setValue(False)'
-
- enableThis = 'nuke.thisNode()[nuke.thisNode()["knobName2"].value()].setExpression("$gui?gui:farm")\nnuke.thisNode()["GUIFarmEnabled"].setValue(True)'
-
-
-
- global guiFarmPreview
-
- if nuke.thisNode().knob('GUIFarm'):
-
- nuke.message('GUI/Farm already exists')
-
- else:
-
- knobName = nuke.thisKnob().name()
-
- nuke.selectedNode().addKnob(nuke.Tab_Knob('GUIFarm', 'GUI/Farm'))
- nuke.selectedNode().addKnob(nuke.String_Knob('knobName2', 'Knob name'))
- nuke.selectedNode().addKnob(nuke.Text_Knob('guiInfo', 'Disable on:'))
- nuke.selectedNode().addKnob(nuke.Boolean_Knob('gui',))
- nuke.selectedNode().addKnob(nuke.Boolean_Knob('farm'))
- nuke.selectedNode().addKnob(nuke.PyScript_Knob('enableThis', 'Enable'))
- nuke.selectedNode().addKnob(nuke.PyScript_Knob('disableThis', 'Disable'))
-
- nuke.selectedNode().addKnob(nuke.Boolean_Knob('GUIFarmEnabled'))
-
- nuke.selectedNode().knob('knobName2').setValue(knobName)
- nuke.selectedNode().knob('knobName2').setEnabled(False)
-
- nuke.selectedNode().knob('enableThis').setValue(enableThis)
- nuke.selectedNode().knob('disableThis').setValue(disableThis)
-
- nuke.selectedNode().knob('GUIFarmEnabled').setValue(True)
- nuke.selectedNode().knob('GUIFarmEnabled').setVisible(False)
- nuke.selectedNode().knob('gui').setValue(True)
-
- if guiFarmPreview == True:
- nuke.selectedNode().knob(knobName).setExpression('farm')
-
-
- if guiFarmPreview == False:
- nuke.selectedNode().knob(knobName).setExpression('$gui?gui:farm')
-
-
-
-
-
-
- def buildDisable():
-
-
-
-
- disableThis = 'nuke.thisNode()[nuke.thisNode()["knobName2"].value()].clearAnimated()\nnuke.thisNode()["GUIFarmEnabled"].setValue(False)\nnuke.thisNode()[nuke.thisNode()["knobName2"].value()].setValue(False)'
-
- enableThis = 'nuke.thisNode()[nuke.thisNode()["knobName2"].value()].setExpression("$gui?gui:farm")\nnuke.thisNode()["GUIFarmEnabled"].setValue(True)'
-
- if nuke.selectedNode().knob('GUIFarm'):
-
- nuke.message('GUI/Farm already exists')
-
- else:
-
- knobName = 'disable'
-
- nuke.selectedNode().addKnob(nuke.Tab_Knob('GUIFarm', 'GUI/Farm'))
- nuke.selectedNode().addKnob(nuke.String_Knob('knobName2', 'Knob name'))
- nuke.selectedNode().addKnob(nuke.Text_Knob('guiInfo', 'Disable on:'))
- nuke.selectedNode().addKnob(nuke.Boolean_Knob('gui',))
- nuke.selectedNode().addKnob(nuke.Boolean_Knob('farm'))
- nuke.selectedNode().addKnob(nuke.PyScript_Knob('enableThis', 'Enable'))
- nuke.selectedNode().addKnob(nuke.PyScript_Knob('disableThis', 'Disable'))
-
- nuke.selectedNode().addKnob(nuke.Boolean_Knob('GUIFarmEnabled'))
-
- nuke.selectedNode().knob('knobName2').setValue(knobName)
- nuke.selectedNode().knob('knobName2').setEnabled(False)
- nuke.selectedNode().knob(knobName).setExpression('$gui?gui:farm')
- nuke.selectedNode().knob('enableThis').setValue(enableThis)
- nuke.selectedNode().knob('disableThis').setValue(disableThis)
- nuke.selectedNode().knob('GUIFarmEnabled').setValue(True)
- nuke.selectedNode().knob('GUIFarmEnabled').setVisible(False)
- nuke.selectedNode().knob('gui').setValue(True)
-
-
-
-
- def togglePreview():
-
- global guiFarmPreview
-
- guiFarmPreview = not guiFarmPreview
-
- if guiFarmPreview == True:
-
- for i in nuke.allNodes():
- for k in i.knobs():
- if i.knob(k).name() == "knobName2" and i.knob("GUIFarmEnabled").value() == True:
- knobName = i.knob("knobName2").value()
- i.knob(knobName).setExpression("farm")
-
- elif guiFarmPreview == False:
-
- for i in nuke.allNodes():
- for k in i.knobs():
- if i.knob(k).name() == "knobName2" and i.knob("GUIFarmEnabled").value() == True:
- knobName = i.knob("knobName2").value()
- i.knob(knobName).setExpression("$gui?gui:farm")
-
- def enableAll():
-
- for i in nuke.allNodes():
- for k in i.knobs():
- if i.knob(k).name() == "knobName2":
- knobName = i.knob("knobName2").value()
- i.knob(knobName).setExpression("$gui?gui:farm")
- i.knob("GUIFarmEnabled").setValue(True)
-
- def disableAll():
-
- for i in nuke.allNodes():
- for k in i.knobs():
- if i.knob(k).name() == "knobName2":
- knobName = i.knob("knobName2").value()
- i.knob(knobName).clearAnimated()
- i.knob(knobName).setValue(False)
- i.knob("GUIFarmEnabled").setValue(False)
-
-
|