Skip to content

Instantly share code, notes, and snippets.

View nrhancock's full-sized avatar

Nate H. nrhancock

View GitHub Profile
import maya.cmds as cmds
def transfer_blendshapes():
selection = cmds.ls(selection=True)
if len(selection) != 2:
print("Please select two objects. Select the source mesh first, then the target mesh.")
return
source_mesh = selection[0]
import maya.cmds as cmds
import maya.api.OpenMaya as om
def create_curve_from_joints():
selection = cmds.ls(selection=True, type='joint')
if len(selection) < 2:
cmds.warning('Please select at least two joints.')
return
positions = [om.MVector(cmds.xform(j, q=True, ws=True, t=True)) for j in selection]
degree = 1 if len(positions) == 2 else 3
import maya.cmds as cmds
def findSkin(target):
shapeHistory = cmds.listHistory(target, lv=0)
skin = cmds.ls(shapeHistory, typ='skinCluster')
if len(skin) > 0:
skin = skin[0]
else:
skin = None
return skin
@nrhancock
nrhancock / nrhVendingMachine.py
Created June 7, 2022 18:46
Back to basics python series, this script is a vending machine, run the code, prompt the user to type the desired item from the given list in the prompt, if it matches the machine will prepare a drink if it does not match then it will ask to start again
import maya.cmds as cmds
import pymel.core as pm
#list items
itemList = ['Soda', 'Juice', 'Tea', 'Water']
#prompt user
userPrompt = cmds.promptDialog(title='Beverages', message='We have Soda, Juice, Tea, or Water. Enter your selection: ', button=['OK', 'Cancel'], defaultButton='OK', cancelButton='Cancel', dismissString='Cancel')
if userPrompt == 'OK':
@nrhancock
nrhancock / cardGenerator.py
Created June 1, 2022 20:22
Back to basics, generate a random card with a suit and value
import pymel.core as pm
import maya.cmds as cmds
import random
class cardGenerate():
def __init__(self):
@nrhancock
nrhancock / nrhBuildJointsOnCurve
Last active July 14, 2022 20:08
Run script, create a curve, indicate desired amount of joints, run and done.
# Quick build joints on a curve tool with UI by Nate Hancock
# Simply run script, follow UI prompts and done!
#last update 07/14/2022
import pymel.core as pm
import maya.cmds as cmds
#class in for variable
class nrhCurver():
@nrhancock
nrhancock / nrh_timeTo_aHundred.py
Created May 29, 2022 19:40
Back to basics, calculate time to 100 years old.
current_age = input("What is your current age?")
value_age = int(current_age)
years_toGo = 100 - value_age
weeks_toGo = years_toGo * 52
days_toGo = years_toGo * 365
time_to_hundred = f"You have {years_toGo} years, {weeks_toGo} weeks, and {days_toGo} until age 100."
print(time_to_hundred)
@nrhancock
nrhancock / spaceswitch_Tool_setup.py
Created May 15, 2021 23:09
Complex space switch tool utilizing shared constraints and bypassing cycle, easy space switching for animation
# Nathaniel H.
# 04/29/2021
# v4 updated 5/12/2021
# Quick setup for complex space switching tool
import pymel.core as pm
@nrhancock
nrhancock / makeFKControls.mel
Created February 8, 2021 17:29
Nate's Rigging toolset for Maya
global proc makeFKTR ()
{
// sets up FK controls to a joint chain of any size
// usage: makeFKTRS (requires makeFK UI)
// capturing variables
$selection = `ls -sl`;
int $size = `size ($selection)`;
float $controlSize = `floatSliderGrp -q -v controlSize`;