Skip to content

Instantly share code, notes, and snippets.

@fredrikaverpil
Last active May 20, 2024 20:31
Show Gist options
  • Save fredrikaverpil/9760964 to your computer and use it in GitHub Desktop.
Save fredrikaverpil/9760964 to your computer and use it in GitHub Desktop.
Get and set knob values #nuke
# Get all nodes of type Read
readnodes = nuke.allNodes('Read')
for readnode in readnodes:
print readnode
# List all knobs for selected node
print( nuke.toNode('Read1') )
# List all knobs for specific node
print( nuke.selectedNode() )
# Get value from specific node
value = nuke.toNode('Read1').knob('file').getValue()
# Get value from selected node
value = nuke.selectedNode().knob('file').getValue()
# Get value from this node
value = nuke.thisNode().knob('file').getValue()
# Get value from specific node and evaluate it (good for expressions)
value = nuke.toNode('Read1').knob('file').evaluate()
# Set specific node's value
nuke.toNode('Read1').knob('file').setValue('c:/hello.tif')
# Set selected node's value
nuke.selectedNode().knob('file').setValue('c:/hello.tif')
# Set this node's value
nuke.thisNode().knob('file').setValue('c:/hello.tif')
# Set specific node's knob to default value
nuke.toNode('Grade1').knob('gamma').setValue( nuke.toNode('Grade1').knob('gamma').defaultValue() )
@Arslan-TR
Copy link

Arslan-TR commented Feb 4, 2021

so the problem is its not working when i set #folder by expression link it giving error like this:

# Result: Traceback (most recent call last):
  File "<string>", line 4, in <module>
TypeError: 'bool' object is not iterable
  • so i tried to print folder value as string to an other variable but it didnt work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment