Skip to content

Instantly share code, notes, and snippets.

@plasmax
plasmax / viewerscrub.py
Last active September 10, 2020 19:16
Allows you to scrub in the viewer by holding Alt+Meta.
# Allows you to scrub in the viewer by holding Alt+Meta. Inspired by Max van Leeuwen's SmoothScrub
import nuke
from PySide2.QtWidgets import QApplication
from PySide2.QtCore import QObject, QCoreApplication, QEvent, Qt, QPoint
class ViewerScrub(QObject):
def __init__(self):
super(ViewerScrub, self).__init__()
@plasmax
plasmax / single_selection_latest.py
Created July 6, 2019 12:27
Sublime plugin that does what the single_selection command does, but instead of jumping back to the first selection, will remain on the latest.
r"""
Sublime plugin that does what the single_selection command does,
but instead of jumping back to the first selection, will remain
on the latest.
Installation:
Save in packages directory (Preferences/Browse Packages in Sublime Text 3).
\Sublime Text 3\Packages\User\single_selection_latest.py
Add shortcut (Preferences/Key Bindings).
@plasmax
plasmax / objc_util.py
Created February 24, 2019 15:12 — forked from tlinnet/objc_util.py
objc_util.py
# coding: utf-8
__all__ = ['c', 'LP64', 'CGFloat', 'NSInteger', 'NSUInteger', 'NSNotFound', 'NSUTF8StringEncoding', 'NS_UTF8', 'CGPoint', 'CGSize', 'CGVector', 'CGRect', 'CGAffineTransform', 'UIEdgeInsets', 'NSRange', 'sel', 'ObjCClass', 'ObjCInstance', 'ObjCClassMethod', 'ObjCInstanceMethod', 'NSObject', 'NSArray', 'NSMutableArray', 'NSDictionary', 'NSMutableDictionary', 'NSSet', 'NSMutableSet', 'NSString', 'NSMutableString', 'NSData', 'NSMutableData', 'NSNumber', 'NSURL', 'NSEnumerator', 'NSThread', 'NSBundle', 'UIColor', 'UIImage', 'UIBezierPath', 'UIApplication', 'UIView', 'ObjCBlock', 'ns', 'nsurl', 'retain_global', 'release_global', 'on_main_thread', 'create_objc_class',
'Structure', 'sizeof', 'byref', 'c_void_p', 'c_char', 'c_byte', 'c_char_p', 'c_double', 'c_float', 'c_int', 'c_longlong', 'c_short', 'c_bool', 'c_long', 'c_int32', 'c_ubyte', 'c_uint', 'c_ushort', 'c_ulong', 'c_ulonglong', 'POINTER', 'pointer', 'load_framework', 'nsdata_to_bytes', 'uiimage_to_png']
try:
import ctypes
except ImportErr
@plasmax
plasmax / parser.py
Created February 22, 2019 22:29 — forked from julik/parser.py
Yo dawg, I heard you like Nuke so I wrote this so that you can parse your Nuke TCL while you tickle yo' Python. Ya dig?
TERMINATORS = ["\n", ";"]
ESC = "\\"
QUOTES = ['"', "'"]
class c:
"""
Will be at the start of a list representing an expression
in curly braces. Every c() is equal to any other c()
"""
@plasmax
plasmax / nk_black_to_white.py
Created February 22, 2019 22:19
# a simple parser to extract nodes from .nk files
# a simple parser to extract nodes from .nk files
nuke.removeKnobChanged(grade_knobChanged)
nuke.removeOnCreate(grade_by_order)
nuke.removeOnDestroy(grade_by_order)
def grade_by_order():
import sys
sys.path.append('/job/pipeline/dev/sandbox/sandbox_mlast/work/mlast/git/.nuke/python/scripts/notmine/')
@plasmax
plasmax / ImagineRenderIop
Created October 2, 2018 06:58 — forked from ppearson/ImagineRenderIop
ImagineRender_Iop
/*
Imagine
Copyright 2011 Peter Pearson.
Licensed under the Apache License, Version 2.0 (the "License");
You may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@plasmax
plasmax / nuke_camera_navigator.py
Created September 30, 2018 20:17
Small panel that enables WASD (+QE and F) control for Foundy's NUKE cameras
import math
import nuke
try:
from PySide2 import QtWidgets, QtCore
except ImportError:
from PySide import QtGui as QtWidgets
from PySide import QtCore
def median(lst):
@plasmax
plasmax / Makefile
Created September 4, 2018 18:31
makefile for test_convertexr.cpp
OPENEXRDIR ?= /opt/openexr-2.2
EXRINCLUDE ?= -I$(OPENEXRDIR)/include/OpenEXR
EXRLIBPATH ?= -L$(OPENEXRDIR)/lib64
CXXFLAGS ?= -c $(EXRINCLUDE) -fPIC -msse
LINKFLAGS ?= -std=c++11 $(EXRLIBPATH) \
-lz \
-lpthread \
-lm \
-lrt \
@plasmax
plasmax / test_convertexr.cpp
Created September 4, 2018 18:29
test_convertexr
#include <ImfRgba.h>
#include <ImfRgbaFile.h>
#include <ImfArray.h>
#include <ImathBox.h>
#include <stdio.h>
#include <iostream> // std::cout
#include <algorithm> // std::min
using namespace Imf;
@plasmax
plasmax / sticky_drop.py
Created August 14, 2018 00:20
drop event override to automatically create stickynotes
from PySide import QtGui, QtCore
import ast
import nukescripts
def paste_sticky():
try:
nuke.nodePaste('%clipboard%')
except Exception: