Skip to content

Instantly share code, notes, and snippets.

View MongoWobbler's full-sized avatar
👨‍🍳
cooking

Christian Corsica MongoWobbler

👨‍🍳
cooking
View GitHub Profile
@MongoWobbler
MongoWobbler / mirror.py
Last active March 29, 2022 00:41
Function and decorator to avoid writing two functions when arguments are swappable, such as "left" and/or "right"
import re
import pymel.core as pm
left_name = 'Left '
left_suffix = '_l'
left_tag = '_l_'
right_name = 'Right '
right_suffix = '_r'
import pymel.core as pm
def selectVertsBelowThreshold(joints=None, threshold=1.0):
"""
Selects all the vertices of the given or selected joints that have a weight below the given threshold.
Args:
joints (list): Joints to get influencing vertices from.
@MongoWobbler
MongoWobbler / blobber.py
Last active July 6, 2021 03:10
Example of how to use piper.mayapy.rig to rig the Blobber character
from piper.mayapy.rig import Rig
with Rig() as rig:
root_ctrl = rig.root()[1][0]
pelvis_ctrl = rig.FK('pelvis', name='Pelvis', parent=root_ctrl)[1][0]
butt_ctrl = rig.extra('pelvis', 'butt', scale=1.05, spaces=[pelvis_ctrl])
_, mouth_ctrls, _ = rig.FK('mouth', 'lips', parent=pelvis_ctrl, name='Mouth')
[rig.FK(joint, parent=pelvis_ctrl, axis='y', name='Hair') for joint in ['hair_back', 'hair_mid', 'hair_front']]
@MongoWobbler
MongoWobbler / proximity_wrap.py
Last active September 7, 2023 07:46
Function for creating a proximity wrap deformer in Maya with the given source driving the given target
import maya.cmds as cmds
import maya.internal.nodes.proximitywrap.node_interface as node_interface
def createProximityWrap(source, target):
"""
Creates a proximity with the given source and target transforms.
Args:
source (pm.nodetypes.Transform): Transform with skinned mesh that will drive given target.
import pymel.core as pm
def orientToVertex(transform, vertex):
"""
Orients the given transform to the given vertex's normal. Up/Side orientation is likely to be random.
Args:
transform (pm.nodetypes.Transform): Node to orient to given vertex.
@MongoWobbler
MongoWobbler / register_repeat_last.py
Last active April 27, 2021 00:46
register given python function to maya's repeat last
import pymel.core as pm
def registerRepeatLast(function):
"""
Registers the given function to the repeat last command.
Args:
function (function): Function/method to register to repeat last.
"""
@MongoWobbler
MongoWobbler / origin_cross_section.py
Last active April 27, 2021 00:46
Creates a curve at the origin that is the shape of the cross section outline of the given meshes.
import maya.OpenMaya as om
import pymel.core as pm
def originCrossSection(meshes=None, side='', name=None, tolerance=128.0, clean_up=True):
"""
Creates a curve at the origin that is a cross section of the given mesh(es).
Args:
meshes (list): pm.nodetypes.Transform with mesh shapes as children to create curves from.
@MongoWobbler
MongoWobbler / maya_qt_util.py
Last active August 11, 2023 09:00
Way of getting maya's main window and main menu as a QtWidget
import sys
from PySide2 import QtWidgets
from shiboken2 import wrapInstance
import maya.OpenMayaUI as omui
if sys.version_info > (3,):
long = int
# QObjects fall out of scope, so making them global here to keep them in scope