Skip to content

Instantly share code, notes, and snippets.

View kpprt's full-sized avatar

Christian Kauppert kpprt

View GitHub Profile
@kpprt
kpprt / reload_all_precomps.py
Created March 7, 2016 18:10
Reload all precomps in a Nuke comp
import nuke
for n in nuke.allNodes():
k = n.knob('reload_script')
if k != None:
print 'reloading ' + n.name()
k.execute()
@kpprt
kpprt / render_sequentially.py
Created March 7, 2016 18:14
Render all selected nodes one after another in Nuke
import nuke
for n in nuke.selectedNodes():
if n.Class() != 'Write':
continue
print 'Executing ' + n.name()
nuke.execute(n)
@kpprt
kpprt / reload_all_nodes.py
Created March 17, 2016 15:59
Reload all nodes with a reload button in Nuke
for n in nuke.allNodes():
r = n.knob('reload')
if r != None:
r.execute()
@kpprt
kpprt / make_file_paths_relative.py
Last active September 3, 2017 17:29
Make all file references relative in a Nuke script when they start with the project directory (case-sensitive)
def remove_prefix(text, prefix):
if text.startswith(prefix):
return text[len(prefix):]
return text
undo = nuke.Undo()
undo.begin("make file paths relative")
project_dir = nuke.Root()['project_directory'].value()
if not project_dir.endswith('/'):
@kpprt
kpprt / serialize_node.py
Last active March 17, 2016 18:12
Serialize a node to text in a NoOp node in Nuke. This could be helpful if some nodes of plugins etc. are causing problems on other machines like render slaves even if they are not connected in the node tree, but you also don't want to delete them.
# TODO:
# disconnect the SerializedNode completely
# set the position of the SerializedNode to the source node
# optional: after restoring the source node, reconnect all former inputs correctly
# (could be tricky when the script has changed in the meantime)
# optional: create the invisible node via python instead of pasting TCL code
for n in nuke.selectedNodes():
node_as_string = 'set cut_paste_input [stack 0]\npush $cut_paste_input\n' + n.Class() + ' {'
node_as_string += n.writeKnobs(nuke.TO_SCRIPT | nuke.WRITE_ALL)
@kpprt
kpprt / CS_CropToBBox.tcl
Last active March 7, 2019 17:51
Dynamically crop to the current or an external bounding box in Nuke. This might save performance e.g. when piping in a roto shape bbox of a garbage matte.
set cut_paste_input [stack 0]
version 10.5 v7
push $cut_paste_input
Group {
name CS_CropToBBox1
tile_color 0xa57aaaff
addUserKnob {20 CS_CropToBBox}
addUserKnob {41 numpixels l "Add Pixels" T AdjBBox1.numpixels}
addUserKnob {41 softness T Crop1.softness}
addUserKnob {41 reformat T Crop1.reformat}
@kpprt
kpprt / CS_EdgeExtend.tcl
Last active February 10, 2018 18:17
A simple edge extend node for Nuke.
set cut_paste_input [stack 0]
version 9.0 v8
push 0
push $cut_paste_input
Group {
inputs 2
name CS_EdgeExtend1
selected true
xpos -150
ypos 1214
@kpprt
kpprt / bash_snippets.sh
Last active August 8, 2017 16:46
A collection of short one line bash snippets.
#!/bin/bash
# find hidden files recursively from the current folder which file names are not starting with a dot
find . -flags +hidden -name \[\!.\]\*
# unhide all files recursively from the current folder which file names are not starting with a dot
find . -flags +hidden -name \[\!.\]\* -exec chflags nohidden {} \;
# simple search and replace in all file names of current folder
# echo is there for preview, remove it to actually execute the command
@kpprt
kpprt / CS_STMap.tcl
Created April 11, 2016 09:47
Simple STMap for Nuke that also supports alpha.
set cut_paste_input [stack 0]
version 9.0 v8
CheckerBoard2 {
inputs 0
format "1920 1080 0 0 1920 1080 1 HD_1080"
name CheckerBoard1
selected true
xpos -150
ypos -417
}
@kpprt
kpprt / CS_ColorCorners.tcl
Created April 12, 2016 15:03
Create color overlays at the corners of an image in Nuke. Might be helpful for matching colors of a corner pin.
set cut_paste_input [stack 0]
version 9.0 v8
push $cut_paste_input
Group {
name CS_ColorCorners1
selected true
xpos 840
ypos -130
addUserKnob {20 CS_ColorCorners}
addUserKnob {20 corner1 l "Bottom Left Corner" n 1}