Disable knobs on a certain node with python
1 2 |
x = nuke.toNode("YourNode") x['knob'].setEnabled(False) |
To do this for all knobs, just put it in a loop:
1 2 3 4 5 |
x = nuke.toNode("YourNode") x['knob'].setEnabled(False) for i in x.allKnobs(): [i.name()].setEnabled(False) |
Execute writenode via python
1 2 3 |
write = nuke.toNode('YourWritenode') nuke.execute(write,firstframe,lastframe) |
Set keyframes in knobs with python
This example sets a knob to a defined value in all frames .
nuke.Root()[‘first_frame’].getValue() returns float whyever…
So thats the reason i put it in “int()”
1 2 3 4 5 6 7 8 9 10 11 12 |
x = nuke.toNode("YourNode") # get first an last frame from Script and convert them into integer first = int(nuke.Root()['first_frame'].getValue()) last = int(nuke.Root()['last_frame'].getValue()) x['knobname'].setAnimated(0) # set value in all frames for i in range(first,last): nuke.activeViewer().frameControl(i) x['knobname'].setValueAt(value,i) |
Create knobs with python
Syntax to create knobs (in this example a text-knob):
1 2 3 |
c = nuke.toNode("YourNode") text = nuke.Text_Knob(name,label,"text") c.addKnob(knob) |
And here a short list of the most-needed knobs:
1 2 3 4 |
nuke.PyScript_Knob(name,label,py-script) nuke.Text_Knob(name,label,Text) nuke.Boolean_Knob(name,label) nuke.Enumeration_Knob(name,label,['value1', 'value2', 'value3']) |
Hide unconnected inputs on selected nodes
Just a few lines to hide all not connected inputs. In this example the script touches all Beziers.
1 2 3 4 5 6 7 |
for x in nuke.allNodes("Bezier"): if x.input(0): pass else: x["hide_input"].setValue("1") print x["label"].value() |
Export Nuke’s LUT to FrameCycler
FrameCycler can be a bitch to work with. In order to get the colours right, you can do the following: (more…)
Colour blend modes in Photoshop
Comprehensive info:
http://stackoverflow.com/questions/5919663/how-does-photoshop-blend-two-images-together
Sample image from within the expression node
To sample the incoming colour values, in an expression node type the following for the required channels:
1 |
y==floor(r(x, pos.y)*height*mult)?1:0 |
Split file path in TCL
To split the contents of a file value field in read or write nodes, you can type this expression:
1 |
[lrange [split [value file] _ ] 10 10 ] |
Convert rgb to hex colour in python
For some things, like the tile colour of a node, you can’t work with rgb but need to use hex values instead. You can use the following code to convert rgb to hex:
1 |
hexColour = int('%02x%02x%02x%02x' % (r*255,g*255,b*255,1),16) |
So, to set a random tile colour for the selected node, type:
1 2 3 4 5 6 7 |
import random n = nuke.selectedNode() r = (float(random.randint( 20, 40)))/100 g = (float(random.randint( 10, 50)))/100 b = (float(random.randint( 15, 60)))/100 hexColour = int('%02x%02x%02x%02x' % (r*255,g*255,b*255,1),16) n['tile_color'].setValue( hexColour ) |