Skip to content

Instantly share code, notes, and snippets.

View theodox's full-sized avatar

Steve Theodore theodox

View GitHub Profile
@theodox
theodox / xform.py
Created March 11, 2014 21:52
Exposes the xform class: a simple way to set maya position, rotation and similar properties with point notation.
'''
xform.py
Exposes the xform class: a simple way to set maya position, rotation and similar properties with point notation.
from xform import Xform
example = Xform('pCube1')
print example.translation
# [0,0,0]
@theodox
theodox / UnrealQT.py
Last active February 3, 2023 02:46
Delegates UnrealEd draw ticks to a PySide2 Application, allowing non-blocking updates
"""
"""
import unreal
import PySide2.QtWidgets as widgets
import traceback
class UEQApplication (widgets.QApplication):
"""
Ensure that an application never tries to `exec_` inside of Unreal
@theodox
theodox / mayaPyManager.py
Last active January 17, 2023 09:50
Exposes the MayaPyManager class, which is used to run instances of MayaPy with explict control over paths and environment variables. A Manager can run scripts, modules, or command strings in a separate MayaPy environment; results and errors are captured and returned.
'''
Exposes the MayaPyManager class, which is used to run instances of MayaPy with explict control over paths and environment variables. A Manager can run scripts, modules, or command strings in a separate MayaPy environment; results and errors are captured and returned.
Typical uses might be:
- running unit tests
- running a copy of Maya.standalone as a headless RPC server with StandaloneRPC https://github.com/theodox/standaloneRPC
- spawning multipe copies of maya to batch process files in parallel on a multi-core machine
- do any of the above on multiple maya versions concurrently
@theodox
theodox / MayaPyHost
Created November 2, 2018 23:34
interactive mayapy subprocess
"""
MayaPy.py
Remote control of a mayapy session with a simple proxy interface. This is not intended as a complete RPC server or anything of the sort; the primary use case is as an isolation chamber (since you can manipulate paths and environment variables) for use in testing.
"""
import subprocess
import cPickle as pickle
import os
@theodox
theodox / Canvas.py
Created May 4, 2017 17:51
a simple set of tools for working with images using the Maya api
from array import array
from itertools import islice, izip, imap, izip_longest, tee, chain, product, ifilter
from maya.api.OpenMaya import MImage
import ctypes
def image_to_bytearray(img):
"""
@theodox
theodox / FBX Wrapper.py
Last active December 19, 2021 12:05
FBXWrapper
'''
FBXWrapper
This module provides a python wrapper for every method exposed in the FBX plugin.
The arguments for the calls are the same as for the equivalent mel calls, however they can be passed with typical
python syntax, which is translated to mel-style flags and arguments under the hood. The actual flags and arguments
are documented here:
usage:
def add_tool(name, exe, commandline, shortcut=''):
'''
Adds a command entry to a tools list container node.
* tool_list_element is ElementTree node representing the tools list
* exe is the path to the executable
* commandline is the arguments passed to the commandline.
* shortcut is a key shortcut
If a tool with the same name already exists, it will be overwritten
Perforce supports special characters in the command lines, which
will be replaced at call time. see
@theodox
theodox / PhotoshopSockets.js
Last active December 15, 2020 21:05
A simple server that can be run inside photoshop, demonstrating how to respond to socket calls
// requires photoshop CS5+
// create a new socket
conn = new Socket();
var keep_serving = true;
// sample functions. In a real application you'd have handler functions that could accept more complex inputs
var alrt = alert; // pop a dialog
var newLayer = function () { return app.activeDocument.artLayers.add(); }; // make a layer
var stop = function () { keep_serving = false; }; // stop the server
@theodox
theodox / melfunction.py
Last active August 25, 2019 19:49
Tools for wrapping rogue mel commands
melfunction.py
"""
Provides tools for wrapping mel commands for more Pythonic access.
Note this is a supplement to maya.cmds, not a replacement for it! This is intended to provide
similar coverage for un-translated MEL or commands fron plugins which don't respect the
ordinary cmds conventions.
Legalese:
@theodox
theodox / Matrix.hlsl
Created April 27, 2019 23:20 — forked from mattatz/Matrix.hlsl
Matrix operations for HLSL
#ifndef __MATRIX_INCLUDED__
#define __MATRIX_INCLUDED__
#define IDENTITY_MATRIX float4x4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
float4x4 inverse(float4x4 m) {
float n11 = m[0][0], n12 = m[1][0], n13 = m[2][0], n14 = m[3][0];
float n21 = m[0][1], n22 = m[1][1], n23 = m[2][1], n24 = m[3][1];
float n31 = m[0][2], n32 = m[1][2], n33 = m[2][2], n34 = m[3][2];
float n41 = m[0][3], n42 = m[1][3], n43 = m[2][3], n44 = m[3][3];