Nessuna descrizione
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

guiFarm.py 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # GUIFarm by Andreas Gebauer
  2. # 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.
  3. # 1. Select node and press SHIFT + D.
  4. # 2. Set values in the 'gui' and 'farm' fields. By default node is True in gui and False on farm.
  5. # 3. Globally turn them on and off in the top GUIFarm menu with "Toggle preview"
  6. # GUIFarm Menu:
  7. # Disable all: Removes expressions from all GUIFarm affected nodes and sets disable knob to False.
  8. # Enable all: Enables all GUIFarm affected nodes and sets $gui expression.
  9. # You can use this on other boolean knobs as well but I haven' really tested it.
  10. import nuke
  11. guiFarmPreview = False
  12. def build():
  13. disableThis = 'nuke.thisNode()[nuke.thisNode()["knobName2"].value()].clearAnimated()\nnuke.thisNode()["GUIFarmEnabled"].setValue(False)\nnuke.thisNode()[nuke.thisNode()["knobName2"].value()].setValue(False)'
  14. enableThis = 'nuke.thisNode()[nuke.thisNode()["knobName2"].value()].setExpression("$gui?gui:farm")\nnuke.thisNode()["GUIFarmEnabled"].setValue(True)'
  15. global guiFarmPreview
  16. if nuke.thisNode().knob('GUIFarm'):
  17. nuke.message('GUI/Farm already exists')
  18. else:
  19. knobName = nuke.thisKnob().name()
  20. nuke.selectedNode().addKnob(nuke.Tab_Knob('GUIFarm', 'GUI/Farm'))
  21. nuke.selectedNode().addKnob(nuke.String_Knob('knobName2', 'Knob name'))
  22. nuke.selectedNode().addKnob(nuke.Text_Knob('guiInfo', 'Disable on:'))
  23. nuke.selectedNode().addKnob(nuke.Boolean_Knob('gui',))
  24. nuke.selectedNode().addKnob(nuke.Boolean_Knob('farm'))
  25. nuke.selectedNode().addKnob(nuke.PyScript_Knob('enableThis', 'Enable'))
  26. nuke.selectedNode().addKnob(nuke.PyScript_Knob('disableThis', 'Disable'))
  27. nuke.selectedNode().addKnob(nuke.Boolean_Knob('GUIFarmEnabled'))
  28. nuke.selectedNode().knob('knobName2').setValue(knobName)
  29. nuke.selectedNode().knob('knobName2').setEnabled(False)
  30. nuke.selectedNode().knob('enableThis').setValue(enableThis)
  31. nuke.selectedNode().knob('disableThis').setValue(disableThis)
  32. nuke.selectedNode().knob('GUIFarmEnabled').setValue(True)
  33. nuke.selectedNode().knob('GUIFarmEnabled').setVisible(False)
  34. nuke.selectedNode().knob('gui').setValue(True)
  35. if guiFarmPreview == True:
  36. nuke.selectedNode().knob(knobName).setExpression('farm')
  37. if guiFarmPreview == False:
  38. nuke.selectedNode().knob(knobName).setExpression('$gui?gui:farm')
  39. def buildDisable():
  40. disableThis = 'nuke.thisNode()[nuke.thisNode()["knobName2"].value()].clearAnimated()\nnuke.thisNode()["GUIFarmEnabled"].setValue(False)\nnuke.thisNode()[nuke.thisNode()["knobName2"].value()].setValue(False)'
  41. enableThis = 'nuke.thisNode()[nuke.thisNode()["knobName2"].value()].setExpression("$gui?gui:farm")\nnuke.thisNode()["GUIFarmEnabled"].setValue(True)'
  42. if nuke.selectedNode().knob('GUIFarm'):
  43. nuke.message('GUI/Farm already exists')
  44. else:
  45. knobName = 'disable'
  46. nuke.selectedNode().addKnob(nuke.Tab_Knob('GUIFarm', 'GUI/Farm'))
  47. nuke.selectedNode().addKnob(nuke.String_Knob('knobName2', 'Knob name'))
  48. nuke.selectedNode().addKnob(nuke.Text_Knob('guiInfo', 'Disable on:'))
  49. nuke.selectedNode().addKnob(nuke.Boolean_Knob('gui',))
  50. nuke.selectedNode().addKnob(nuke.Boolean_Knob('farm'))
  51. nuke.selectedNode().addKnob(nuke.PyScript_Knob('enableThis', 'Enable'))
  52. nuke.selectedNode().addKnob(nuke.PyScript_Knob('disableThis', 'Disable'))
  53. nuke.selectedNode().addKnob(nuke.Boolean_Knob('GUIFarmEnabled'))
  54. nuke.selectedNode().knob('knobName2').setValue(knobName)
  55. nuke.selectedNode().knob('knobName2').setEnabled(False)
  56. nuke.selectedNode().knob(knobName).setExpression('$gui?gui:farm')
  57. nuke.selectedNode().knob('enableThis').setValue(enableThis)
  58. nuke.selectedNode().knob('disableThis').setValue(disableThis)
  59. nuke.selectedNode().knob('GUIFarmEnabled').setValue(True)
  60. nuke.selectedNode().knob('GUIFarmEnabled').setVisible(False)
  61. nuke.selectedNode().knob('gui').setValue(True)
  62. def togglePreview():
  63. global guiFarmPreview
  64. guiFarmPreview = not guiFarmPreview
  65. if guiFarmPreview == True:
  66. for i in nuke.allNodes():
  67. for k in i.knobs():
  68. if i.knob(k).name() == "knobName2" and i.knob("GUIFarmEnabled").value() == True:
  69. knobName = i.knob("knobName2").value()
  70. i.knob(knobName).setExpression("farm")
  71. elif guiFarmPreview == False:
  72. for i in nuke.allNodes():
  73. for k in i.knobs():
  74. if i.knob(k).name() == "knobName2" and i.knob("GUIFarmEnabled").value() == True:
  75. knobName = i.knob("knobName2").value()
  76. i.knob(knobName).setExpression("$gui?gui:farm")
  77. def enableAll():
  78. for i in nuke.allNodes():
  79. for k in i.knobs():
  80. if i.knob(k).name() == "knobName2":
  81. knobName = i.knob("knobName2").value()
  82. i.knob(knobName).setExpression("$gui?gui:farm")
  83. i.knob("GUIFarmEnabled").setValue(True)
  84. def disableAll():
  85. for i in nuke.allNodes():
  86. for k in i.knobs():
  87. if i.knob(k).name() == "knobName2":
  88. knobName = i.knob("knobName2").value()
  89. i.knob(knobName).clearAnimated()
  90. i.knob(knobName).setValue(False)
  91. i.knob("GUIFarmEnabled").setValue(False)