Skip to content

Instantly share code, notes, and snippets.

View justinfx's full-sized avatar

Justin Israel justinfx

View GitHub Profile
@justinfx
justinfx / EyeRig.py
Created July 27, 2011 20:10
python_inside_maya - Rewrite this as a Python Class?
import maya.cmds as cmds
class EyeRig(object):
"""
EyeRig
Usage:
eyeRig = EyeRig()
eyeRig.create('testX_eyeL', 'testX_eyeL_tgt', ['anim', 'aim', 'out'])
@justinfx
justinfx / stress_test.go
Created August 26, 2011 23:37
go-socket.io stress_test
package socketio
import (
"testing"
"os"
"flag"
"strconv"
"sync"
"fmt"
"http"
@justinfx
justinfx / modelPanelPyQt4.py
Created November 21, 2011 03:01
Mixing PyQt4 and Maya UI objects
from PyQt4 import QtCore, QtGui
import maya.cmds as cmds
import maya.OpenMayaUI as mui
import sip
global app
@justinfx
justinfx / modelPanelPyQt4.py
Last active September 15, 2023 03:31
Mixing PyQt4 and Maya UI objects
from PyQt4 import QtCore, QtGui
import maya.cmds as cmds
import maya.OpenMayaUI as mui
import sip
class MyDialog(QtGui.QDialog):
@justinfx
justinfx / mayaVertFaceSelect.py
Created November 27, 2011 20:00
Selecting staggered vert/face from start and stop original selection
import re
import maya.cmds as cmds
def getSelectedInts():
rx = re.compile(r'\[(\d+)\]$')
intList = []
sel = cmds.ls(sl=True)
if not sel:
return "", []
@justinfx
justinfx / interfaces.py
Created December 27, 2011 06:20
An alternative to doing switches in OOP
#!/usr/bin/env python
"""
Based on the this SO question:
http://stackoverflow.com/questions/126409/ways-to-eliminate-switch-in-code
Ways to use object oriented programming to create interfaces
instead of using switch patterns like:
if
elif
@justinfx
justinfx / float2ptr.py
Created January 26, 2012 18:01
Generating a list of Float2 pointers using MScriptUtil
from maya import OpenMaya
import random
import sys
ptrArray = []
numObjs = 4
print "Before"
for obj in range(numObjs):
data = [random.uniform(0,1), random.uniform(0,1)]
import maya.OpenMaya as OpenMaya
from maya.OpenMayaFX import MFnParticleSystem
from maya.OpenMaya import MPoint, MPointOnMesh, MVector, MFloatPoint
import maya.cmds as cmds
import time
from operator import itemgetter
@justinfx
justinfx / pyqt_popup_close.py
Created March 1, 2012 18:00
Example of how to use PyQt to popup a dialog at current mouse pos, and close in response to ESC keyc
from PyQt4 import QtCore, QtGui
class Dialog(QtGui.QDialog):
def __init__(self, parent=None):
super(Dialog, self).__init__(parent)
self.resize(300,200)
def showEvent(self, event):
@justinfx
justinfx / pyqt_attrFieldSliderGrp.py
Created March 9, 2012 15:50
Example of how to set up a widget that replicates a Maya attrFieldSliderGrp
class AttrFieldGroup(QtGui.QWidget):
"""
AttrFieldGroup
Resembles a attrFieldSliderGrp widget in the Maya UI.
This is a basic example. You could go further in setting
up a common setRange() to configure both the text input and
the slider together.
"""