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 / 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 / reset_skin_cluster.py
Last active March 1, 2023 21:31
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 / example_usage.py
Last active April 14, 2024 20:43
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 April 20, 2024 14:07
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 / 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
@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 / python-challenges.md
Last active April 5, 2020 14:44
Simple Python Challenges in Maya

Intro Email:

[COMMENT: This document was originally written to introduce beginners and generalist co-workers who wanted to start using Python. It was meant to go much further than #9, but the project fizzled out.]

Write scripts that do the following, and we can talk about techniques, or ways to improve it. If they are too easy, you can also add options, or a GUI.

Please try to write nice clean code, and make comments. You will be re-using parts of your scripts in future challenges, so it is important for you to be able to read and re-use your code.

PYTHON CHALLENGES

@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 / maya_manipulator_size_hotkeys.py
Created July 9, 2019 21:54
Precisely scale Maya manipulators using addition instead of multiplication
'''
In Autodesk Maya, when you hit - and = to scale the manipulator gizmos, it *multiplies* the size.
So if it is small, it takes a long time to grow. And if it is big, and move in huge increments.
So I use addition and subtraction instead.
This gives you much more precise control.
Map the original ones to shift. _ and + to move in larger increments.
Just a tiny little tweak that helps me size it exactly how I want.
I use the radius of the rotation to measure pivot placement.
'''
@chris-lesage
chris-lesage / soft_selection_weights.py
Last active May 3, 2023 22:08
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.