Skip to content

Instantly share code, notes, and snippets.

@MitchellKehn
MitchellKehn / select_3d_geo_from_search.py
Last active July 12, 2018 00:01
Select all objects in a read geo scene based on whether or not they have a specific substring in their name
search = str(nuke.getInput("select items with this in their name:"))
for node in nuke.selectedNodes("ReadGeo2"):
scene_view = node['scene_view']
all_items = scene_view.getAllItems()
scene_view.setSelectedItems([item for item in all_items if item.find(search) >= 0])
@MitchellKehn
MitchellKehn / DotMatrixKernel.cpp
Last active August 4, 2018 06:21
A BlinkScript Kernel to display an image, filtered by an array of an arbitrary texture input.
/*
Author: Mitchell Kehn
*/
kernel DotMatrixDisplay : ImageComputationKernel <ePixelWise>
{
Image <eRead, eAccessRandom, eEdgeClamped> src;
Image <eRead, eAccessRandom, eEdgeNone> tex;
Image <eWrite> dst;
local:
from fuzzywuzzy import fuzz
import re
def partialNumberyRatio(stringA, stringB):
stringA = stringA.lower()
stringB = stringB.lower()
digitsA = "".join(sorted([char for char in stringA if char.isdigit()]))
digitsB = "".join(sorted([char for char in stringB if char.isdigit()]))
@MitchellKehn
MitchellKehn / getParent.py
Last active December 24, 2019 10:54
[get nuke node parent] #nuke
node = nuke.thisNode()
nodeName = "root." + node.fullName()
parentName = ".".join(nodeName.split(".")[:-1])
parent = nuke.toNode(parentName)
@MitchellKehn
MitchellKehn / nodeDuplicate.py
Last active December 24, 2019 10:56
[duplicate node] boilerplate for duplicating a node #nuke
node = nuke.toNode("myNode1")
[sel.setSelected(False) for sel in nuke.selectedNodes()]
node.setSelected(True)
nuke.nodeCopy("%clipboard%")
node.setSelected(False)
nuke.nodePaste("%clipboard%")
newNode = nuke.selectedNode()
@MitchellKehn
MitchellKehn / nukeTrackersToASCII.py
Last active December 24, 2019 10:56
[nuke track exporter] Exporter for nuke 2D tracks into PFTrack-importable format. Exporter not quite working, but has some attribute access stuff that could prove useful #nuke #pftrack
"""
Export a nuke tracker node to an ACII file that can be read by PFTrack
"""
from math import sqrt
HEADER = """\
# "Name"
# clipNumber
# frameCount
# frame, xpos, ypos, similarity
@MitchellKehn
MitchellKehn / nodeHash.py
Last active April 1, 2021 01:27
[get the hash string of a node] #nuke
print hex(nuke.selectedNode().opHashes()[0])
@MitchellKehn
MitchellKehn / fspyNukeImporter.py
Last active December 15, 2023 13:12
[Import fSpy JSON to Nuke] load a json file with camera data from fSpy into Nuke for single frame camera alignment https://fspy.io/ #fspy #nuke
import json
import nuke
def Matrix4toList(M):
mVals = []
for i in range(len(M)):
mVals.append(M[i])
return mVals
# --- load file ---
@MitchellKehn
MitchellKehn / nukeBetterTrackerLinker.py
Last active March 31, 2020 04:13
Copy the chosen transform attributes from the selected tracker node onto the transform controls of the selected elements in roto tree
"""
Copy the chosen transform attributes from the selected tracker node
onto the transform controls of the selected elements in roto tree
"""
import nukescripts
import nuke
from PySide2 import QtWidgets, QtCore, QtGui
@MitchellKehn
MitchellKehn / doReplaceGeoFilepath.py
Last active January 27, 2021 06:36
[Replace Alembic Filepath] replaces the filepath of an alembic readgeo node without popping up a dialog, and preserving the selection and imports with sensible rules #nuke
from altpipe.nuke.utils import replaceReadGeoAbcFilepath
for readgeo in nuke.selectedNodes("ReadGeo2"):
replaceReadGeoAbcFilepath(readgeo, readgeo["file"].getValue().replace("sh010", "sh020"))