Skip to content

Instantly share code, notes, and snippets.

@petfactory
Created September 17, 2014 09:48
Show Gist options
  • Save petfactory/643068ad5b8136149e40 to your computer and use it in GitHub Desktop.
Save petfactory/643068ad5b8136149e40 to your computer and use it in GitHub Desktop.
Toggle a bool knob in nuke
def set_bool_knob(name, all=True, value=None):
if all:
node_list = nuke.allNodes()
else:
node_list = nuke.selectedNodes()
for node in node_list:
if [k for k in node.knobs() if k == name]:
if value is None:
node[name].setValue(not node[name].value())
elif value is False:
node[name].setValue(False)
elif value is True:
node[name].setValue(True)
set_bool_knob('useGPUIfAvailable', all=False)
set_bool_knob('useGPUIfAvailable', value=True)
set_bool_knob('useGPUIfAvailable', value=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment