Skip to content

Instantly share code, notes, and snippets.

View benmorgantd's full-sized avatar

Benjamin Morgan benmorgantd

View GitHub Profile
@benmorgantd
benmorgantd / bm_qtDesignerTemplate.py
Created September 13, 2017 05:45
A template for loading .ui files from QtDesigner and integrating them with Maya 2016.5 or below.
import sys
import os
from PySide import QtCore, QtGui, QtUiTools
import shiboken
import maya.cmds as cmds
import maya.OpenMayaUI as MayaUI
"""
@benmorgantd
benmorgantd / bm_paintTools.py
Created August 21, 2017 20:47
Skin Weight Painting Tools for Maya
import maya.cmds as cmds
import maya.mel as mel
# bm_paintTools
# Intelligent tools for attribute painting
# optional values of op (operation) are absolute and smooth. Absolute replaces
def floodSelection(value=0, op="absolute"):
@benmorgantd
benmorgantd / bm_geoCtrl.py
Last active January 4, 2019 05:49
Geometry Control using Nodes
import maya.cmds as cmds
import maya.mel as mel
def geoCtrl(name="geoCtrl_1", geo=[], child=None):
"""
:param name: The name for our geometry control.
:param geo: The list of our face selection. You can just pass it cmds.ls(sl=1)
:param child: The child that our control will manipulate.
:return: [ctrl, ctrlShape]
@benmorgantd
benmorgantd / bm_cleanupTools_UI.py
Last active July 11, 2024 06:43
Scene cleanup tools including naming, labeling, and history/node deletion.
# our standard imports when using pySide
import maya.OpenMayaUI as omui
import maya.cmds as cmds
import maya.mel as mel
from PySide import QtCore
from PySide import QtGui
from shiboken import wrapInstance
@benmorgantd
benmorgantd / bm_nurbsRibbon.py
Last active September 18, 2023 20:14
Nurbs Ribbon: create a ribbon in Maya with j drive joints and k bind joints. Useful for rigging lips, eyebrows, eyelids, forearms...
# bm_nurbsRibbon
import maya.cmds as cmds
# sets up a ribbon with j drive joints and k bind joints
class NurbsRibbon(object):
def __init__(self, numFollicles=6, numDrivers=3, name="nurbsRibbon"):
if numDrivers <= 1:
return
import maya.cmds as cmds
# copy SDK from one driven node to another
def copySDK():
# 1: Select driven object and then its driver
# 2: Select new driven object and then its driver
sel = cmds.ls(sl=1)
parentDriven = cmds.ls(sl=1)[0]
parentDriver = cmds.ls(sl=1)[1]
import maya.cmds as cmds
# replaces the selected transform's shape with a new one
def changeShape(obj=None,type=None):
shapeTypes = ["cube", "circle", "square", "triangle"]
if type not in shapeTypes:
print "Shape type not recognized"
return
if not obj:
@benmorgantd
benmorgantd / bm_axisDisplay.py
Last active August 12, 2024 07:41
Maya script that forces the Local Rotation Axis display on or off for all joints/transforms or the selected joints/transforms.
import maya.cmds as cmds
# bm_axisDisplay
# Forces the Local Rotation Axis display on or off for all joints or for the selected joints or transforms
def setAxisDisplay(display=False, allObj=False):
# if no joints are selected, do it for all the joints in the scene
# if allObj flag is True then this will toggle the axis display for all objects in the scene, not just joints.
if not allObj:
if len(cmds.ls(sl=1, type="joint")) == 0:
@benmorgantd
benmorgantd / bm_componentToJoint.py
Created March 7, 2017 18:19
Maya script that creates joints on each selected vertex or at the center of each selected edge or face.
import maya.cmds as cmds
def componentToJoint():
if cmds.objectType(cmds.ls(sl=1)[0]) != "mesh":
return
# return the selection as a list
selList = getSelection()
print selList
componentType = selList[0][selList[0].index(".") + 1:selList[0].index("[")]
@benmorgantd
benmorgantd / bm_setInfinite.py
Created March 6, 2017 17:14
Useful for when you want to set Maya SDK values to work beyond their keyed amount.
import maya.cmds as cmds
def setInfinite():
# get active attr in graph editor
activeAttr = cmds.animCurveEditor("graphEditor1GraphEd",q=1,cs=1)
if activeAttr:
for spline in activeAttr:
objName = spline[0:spline.index("_")]
attr = spline[spline.index("_")+1:]