Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Lesage chris-lesage

View GitHub Profile
@chris-lesage
chris-lesage / eye_rigger.py
Created Sep 21, 2020
A temporary WIP alternate eye_rigger for mGear
View eye_rigger.py
"""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 Jan 20, 2021
A Maya script snippet to reset geometry to rest pose after joints have moved
View reset_skin_cluster.py
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 Sep 19, 2022
A script to pin an object to a NurbsSurface in Autodesk Maya
View example_usage.py
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 Jul 7, 2022
Autodesk Maya script to calculate pole vector position based on 3 input objects
View calculate_pole_vector.py
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 Feb 17, 2020
Alternative eye_rigger for mGear. I eventually want to submit this as a PR.
View eye_rigger.py
"""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 Jan 29, 2020
Check skinClusters for too many influences per vertex in Autodesk Maya.
View check_max_influences.py
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 Apr 5, 2020
Simple Python Challenges in Maya
View python-challenges.md

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 Mar 17, 2021
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.
View stepDict_documentation.py
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 Jul 9, 2019
Precisely scale Maya manipulators using addition instead of multiplication
View maya_manipulator_size_hotkeys.py
'''
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 Jul 5, 2022
Get a list of soft selection weights in Autodesk Maya
View soft_selection_weights.py
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.