Skip to content

Instantly share code, notes, and snippets.

View chris-lesage's full-sized avatar

Chris Lesage chris-lesage

View GitHub Profile
@chris-lesage
chris-lesage / example_usage.py
Last active December 31, 2025 10:09
A script to pin an object to a NurbsSurface in Autodesk Maya
import pymel.core as pm
'''
Here are some examples of how to use the pin_to_surface.py script.
'''
# make a nurbsPlane
oNurbs = pm.nurbsPlane(n='nurbsPlane1')
# You can specify the nurbsSurface by string, PyNode transform or PyNode shape.
@chris-lesage
chris-lesage / calculate_pole_vector.py
Last active June 13, 2025 09:23
Autodesk Maya script to calculate pole vector position based on 3 input objects
import pymel.core as pm
'''
An Autodesk Maya PyMEL script that calculates a pole vector position
based on 3 input PyNode objects. example: leg, knee, ankle bones.
Chris Lesage chris@rigmarolestudio.com
'''
def calculate_pole_vector(p1, p2, p3, poleDistance=1):
"""
@chris-lesage
chris-lesage / reset_skin_cluster.py
Last active June 10, 2025 09:49
A Maya script snippet to reset geometry to rest pose after joints have moved
import pymel.core as pm
### SNIPPET Reset Skin Cluster ###
# This script can be used to reset geometry to its neutral rest pose
# after joints have been moved. Use it when making adjustments to your rig/skeleton.
# USAGE: 1. Select the geo 2. Run this script.
# Limitation:
# Sometimes depending on your history, Maya may give an error and fail to reset the geo.
# Sometimes running it twice solves this... ¯\_( ツ )_/¯
@chris-lesage
chris-lesage / eye_rigger.py
Created September 21, 2020 19:18
A temporary WIP alternate eye_rigger for mGear
"""Rigbits eye rigger tool"""
import json
import traceback
from functools import partial
import mgear
import mgear.core.pyqt as gqt
import pymel.core as pm
from maya.app.general.mayaMixin import MayaQWidgetDockableMixin
@chris-lesage
chris-lesage / soft_selection_weights.py
Last active June 10, 2025 09:48
Get a list of soft selection weights in Autodesk Maya
import maya.cmds as cmds
import maya.OpenMaya as omo
# (Open Maya Old)
def soft_selection_weights():
''' create and return a list of the soft selection weights '''
#TODO: Would be nice to rewrite this using the new API. Low priority.
#TODO: Debug on multiple selections
# temporary hack. Turn off symmetry when reading MRichSelection until I learn to use symmetry.
@chris-lesage
chris-lesage / build_slerp_ramp.py
Last active January 15, 2025 03:28
Fake a multi-output lerp/slerp ramp in Autodesk Maya using remapValue nodes. Useful for twisting or interpolating objects and attributes.
import pymel.core as pm
"""
Take a collection of attributes and interpolate them along a curve.
It uses a master remapValue that drives multiple remapValues
to simulate the effect of a multi-out curve node.
References to "twist", because it was originally written for twisting ribbon IK
But it can interpolate any custom attributes you wish
Written by Chris Lesage, June 2019
@chris-lesage
chris-lesage / check_max_influences.py
Created January 29, 2020 23:31
Check skinClusters for too many influences per vertex in Autodesk Maya.
import maya.OpenMaya as OpenMaya
import pymel.core as pm
import maya.OpenMayaAnim as OpenMayaAnim
import maya.cmds as cmds
import maya.mel as mel
class checkMaxSkinInfluences(object):
''' This script takes a mesh with a skinCluster and checks it for N skin weights.
If it has more than N, it selects the verts, so you can edit them.
@chris-lesage
chris-lesage / removeUnusedInfluences.py
Last active July 18, 2024 05:05
Snippet to removeUnusedInfluences in Autodesk Maya using Python.
import maya.cmds as cmds
'''
# EXAMPLE USAGES:
# Removes all unused influences from skinCluster1
remove_unused_influences('skinCluster1')
# Removes the two specified joints from Body_SkinCluster,
but only if they are not currently weighted to anything.
remove_unused_influences('Body_SkinCluster', ['leg_L0_5_jnt', 'leg_R0_5_jnt'])
@chris-lesage
chris-lesage / stepDict_documentation.py
Last active June 14, 2024 07:24
This is a test mGear Shifter POST script that shows how to access the stepDict and all of its information. It's a WIP meant to also act as documentation.
import mgear.shifter.custom_step as cstp
'''
This is a test mGear Shifter POST script that shows how to access the stepDict and all of its information.
It's a WIP meant to also act as documentation.
I'll continue to update it, as I discover more. And hopefully include some of this information in the official mGear docs.
Chris Lesage - chris@rigmarolestudio.com
Justin Pedersen - justin@tcgcape.co.za
Jascha Wohlkinger - jwohlkinger@gmail.com
@chris-lesage
chris-lesage / eye_rigger.py
Created February 17, 2020 20:34
Alternative eye_rigger for mGear. I eventually want to submit this as a PR.
"""Rigbits eye rigger tool"""
"""
This is an alternative eye_rigger for mGear 3.2
I eventually want to submit this as a PR, but I haven't fully tested it yet.
It adds march_vertex() which helps discover the upper and lower edgeloops in the eye.
This can help fix issues on the right side of the rig, where the eye can take weird shapes.
It can also make the eye rig more stable on characters where the eye is at a tilted angle.
Chris Lesage February 2020