Skip to content

Instantly share code, notes, and snippets.

# Time offset start and end of all rotoshapes
import nuke.rotopaint as rp, _curvelib as cl
# Amount of frames to offset
time_offset = -200
t = nuke.frame()
# Get all Roto or RotoPaint nodes and loop through them
roto_nodes = [n for n in nuke.allNodes() if 'Roto' in n.Class()]
for roto_node in roto_nodes:
@jedypod
jedypod / LeftHand_Shortcuts
Last active August 29, 2015 14:06
Map commonly used Nuke functionality to the left hand: frame advancing and stereo view-switching.
# Add these to the menu.py in your ~/.nuke or NUKE_PATH folder
# Viewer Shortcuts
nuke.menu('Viewer').addCommand("Next Frame", lambda: nuke.activeViewer().frameControl(1), "shift+f")
nuke.menu('Viewer').addCommand("Previous Frame", lambda: nuke.activeViewer().frameControl(-1), "shift+d")
nuke.menu('Viewer').addCommand("Next Keyframe", lambda: nuke.activeViewer().frameControl(2), "ctrl+shift+f")
nuke.menu('Viewer').addCommand("Previous Keyframe", lambda: nuke.activeViewer().frameControl(-2), "ctrl+shift+d")
# Swap stereo views: requires eyes to be named as lname and rname
lname = "L"
import nuke.rotopaint as rp, _curvelib as cl, nukescripts, nuke, math, time
class ShapePanel(nukescripts.PythonPanel):
def __init__(self, node):
nukescripts.PythonPanel.__init__(self, 'RotoPaint Elements')
self.rp_node = node
self.frame_range = nuke.String_Knob('frame_range', 'Frame Range', '{0}-{1}'.format(nuke.root().firstFrame(), nuke.root().lastFrame()))
self.type_filter_knob = nuke.Enumeration_Knob('element', 'Element Type', ['Shapes', 'Strokes'])
self.element_knob = nuke.Enumeration_Knob('curve', 'Curve', [])
self.cv_knob = nuke.Enumeration_Knob('cv', 'CV', [])
import nuke, operator
'''
## Add these lines to your menu.py after putting this file somewhere in your NUKE_PATH
# Manipulate nodes in the node graph
import node_handler
nuke.menu('Nuke').addCommand('Edit/Node/Move/Right', 'node_handler.move(1,0)', 'alt+meta+Right')
nuke.menu('Nuke').addCommand('Edit/Node/Move/Left', 'node_handler.move(-1,0)', 'alt+meta+Left')
nuke.menu('Nuke').addCommand('Edit/Node/Move/Up', 'node_handler.move(0,-1)', 'alt+meta+Up')
@jedypod
jedypod / render_writes_with_ranges.py
Last active January 27, 2016 19:40
Render Selected Writes with Individual Frame Ranges - renders each selected write node with the input frame range of that node instead of a single framerange.
import nuke
# nuke.menu('Nuke').findItem('Render').addCommand('Render Selected with Ranges', 'render_writes_with_ranges.render()')
def render():
gui_render = False
write_nodes = nuke.selectedNodes()
write_nodes.sort()
# Get all writes and frame ranges
writes = dict(zip([w for w in write_nodes], [w.frameRange() for w in write_nodes]))
#!/usr/bin/env python
from __future__ import with_statement
import os, re, argparse
# Convert one machine code format to another -
# rename this with no py extension, make it executable, and put it in your bash PATH to make it a commandline tool
# This uses the argparse module to parse args to the commandline tool
parser = argparse.ArgumentParser()
@jedypod
jedypod / BreakdownTransition.nk
Last active March 25, 2017 17:14
Breakdown Transition
Group {
name BreakdownTransition
addUserKnob {20 Breakdown}
addUserKnob {4 transition_type l "Transition Type" M {Dissolve Wipe "Depth Wipe"}}
transition_type Wipe
addUserKnob {3 start_frame l "Start Frame" t "The frame to start the transition on"}
start_frame 1001
addUserKnob {22 set_current_frame l Current t "Sets the start frame to the current frame" -STARTLINE T "n = nuke.thisNode()\nn\['start_frame'].setValue(nuke.frame())"}
addUserKnob {3 transition_length l "Transition Length"}
transition_length 6
@jedypod
jedypod / rsync-time-machine.py
Created April 6, 2017 22:26
My linux rsync time machine script
#!/usr/bin/python
"""
Karl's unix/rsync time-machine script.
Maintains daily and monthly snapshots of a directory tree, hard linked to save
space when files don't change.
Inspired by http://www.mikerubel.org/computers/rsync_snapshots/, but using
more robust coding practices.
Features:
@jedypod
jedypod / GrainResponse.nk
Last active May 31, 2017 19:47
Simple grain node with with intensity response LUT adjustment.
Group {
name GrainResponse
help "Adds synthetic grain. Push \"presets\" to get predefined types of grain, these are the correct size for 2K scans.\n\nYou can also adjust the sliders to match a sample piece of grain. Find a sample with a rather constant background, blur it to remove the grain, and use as input to this. View with a wipe in the viewer so you can make a match. It helps to view and match each of the red, green, blue separately."
addUserKnob {20 GrainTab l Grain}
addUserKnob {3 seed t "Change this value to make different instances of this operator produce different noise"}
seed 134
addUserKnob {35 presets l "" -STARTLINE M {"presets/Kodak 5248" "knobs this \{red_size 3.30 green_size 2.90 blue_size 2.5 red_i 0.60 green_i 0.60 blue_i 0.60 red_m 0.42 green_m 0.46 blue_m 0.85 black 0.00 label \{Kodak 5248\}\}" "presets/Kodak 5279" "knobs this \{red_size 2.70 green_size 2.60 blue_size 2.40 red_i 1.00 green_i 0.76 blue_i 0.65 red_m 0.37 green_m 0.60 blue_m 1.65 black 0.00 label \{Kodak 5279\}\}" "p
@jedypod
jedypod / PNoise.nk
Created June 21, 2017 17:27
One position noise to rule them all.
set cut_paste_input [stack 0]
push $cut_paste_input
add_layer {Pref Pref.red Pref.green Pref.blue Pref.alpha}
Group {
name PNoise
addUserKnob {20 PNoise}
addUserKnob {41 p_channel l "position data" T _POSITION_DATA_.in}
addUserKnob {41 output_channel l output -STARTLINE T _NOISE_OUT_.out}
addUserKnob {6 unpremultiply +STARTLINE}
unpremultiply true