Useful Nuke Python commands
Here is some Nuke python commands and scripts used for production.
Duplicate a node with depencies attached (Shortcut "v"), copy script in "python" user folder:
## add to init.py
nuke.pluginAddPath('./gizmos')
nuke.pluginAddPath('./python')
nuke.pluginAddPath('./icons')
## add to menu.py
import PasteConnected
# Custom Lab Tools
toolbar = nuke.toolbar("Nodes")
m = toolbar.addMenu("Redhat", icon="BHNukeLogo.png")
m.addCommand ("Paste Connected", "PasteConnected.PasteConnected()", 'v')
PasteConnected.py | |
File Size: | 0 kb |
File Type: | py |
Custom Write node change color to green when rendering done and playing sound (add afterRender):
## add to write node afterRender
import winsound
winsound.PlaySound('C:\Windows\Media\Afternoon\Windows Print complete.wav', winsound.SND_ALIAS)
nuke.thisNode().knob('tile_color').setValue( 535101695 ) ;
Custom extract node function, extract node from imput and output without moving node in position, copy script in "python" user folder:
## add to menu.py
import BrExtract
# Custom Lab Tools
toolbar = nuke.toolbar("Nodes")
m = toolbar.addMenu("Redhat", icon="BHNukeLogo.png")
m.addCommand("Extract node", "BrExtract.BrExtract()", "e")
BrExtract.py | |
File Size: | 0 kb |
File Type: | py |
Duplicate a node with depencies attached :
originalNode = nuke.selectedNode()
nuke.nodeCopy('%clipboard%')
nuke.nodePaste('%clipboard%')
copiedNode = nuke.selectedNode()
copiedNode.setInput(0,originalNode.input(0))
Write a text on Nuke script folder :
Txt = "Hello World"
scp = os.path.dirname(nuke.root().name())
FullP = (scp +"/"+ "ReadMe.txt")
if os.path.isfile( FullP ) == False: # if the file doesn't exist
textFile = open(FullP, 'w') # make a new text file
else:
textFile = open(FullP, 'a') # add to the current file
textFile.write( Txt )
textFile.close()