Skip to content

Instantly share code, notes, and snippets.

@EricTRocks
EricTRocks / Maya_InvertShapeWeights.py
Created September 20, 2016 03:43
Invert BlendShape weights
from maya import cmds
import pymel.core as pm
sel = pm.ls(selection=True)
print sel[0]
blends = sel[0].getShape().inputs(type='blendShape')
if len(blends) < 1:
print "No blend shapes on this node!"
else:
@EricTRocks
EricTRocks / createSpline.py
Created September 16, 2016 21:31
Create a Spline with Sub-Curves in 3dsMax 2017
import MaxPlus
p1 = MaxPlus.Point3(0, 0, 0)
p2 = MaxPlus.Point3(0, 30, 0)
p3 = MaxPlus.Point3(10, 30, 0)
p4 = MaxPlus.Point3(10, -20, 0)
obj = MaxPlus.Factory.CreateShapeObject(MaxPlus.ClassIds.SplineShape)
shape = MaxPlus.SplineShape__CastFrom(obj)
@EricTRocks
EricTRocks / createBone.py
Created September 16, 2016 21:31
Create a Bone object in 3dsMax 2017
import MaxPlus
import pymxs
import random
rt = pymxs.runtime
bone = pymxs.runtime.boneSys.createBone(rt.Point3(0, 0, 0), rt.Point3(8, 0, 0), rt.Point3(0,0,1))
hash = random.getrandbits(128)
bone.Name = str(hash)
@EricTRocks
EricTRocks / KLExtReload.py
Created September 6, 2016 20:49
Reload KL Extension from Python
import json
import FabricEngine.Core as fabric
import maya.cmds as cmds
# Get Client
contextID = cmds.fabricSplice('getClientContextID')
if contextID == '':
cmds.fabricSplice('constructClient')
contextID = cmds.fabricSplice('getClientContextID')
@EricTRocks
EricTRocks / Maya_MatchScale.py
Created August 20, 2016 15:38
Maya Match Scale
import maya.cmds as cmds
import pymel.core as pm
def matchScale():
# get selection
sel = pm.ls(selection=True)
if len(sel) < 2:
@EricTRocks
EricTRocks / Maya_MatchTranslation.py
Last active August 20, 2016 15:38
Maya Match Translation
import maya.cmds as cmds
import pymel.core as pm
def matchTranslation():
# get selection
sel = pm.ls(selection=True)
if len(sel) < 2:
@EricTRocks
EricTRocks / Maya_MatchRotations.py
Last active August 20, 2016 15:38
Maya Match Rotations
import maya.cmds as cmds
import pymel.core as pm
def matchRotations():
# get selection
sel = pm.ls(selection=True)
if len(sel) < 2:
@EricTRocks
EricTRocks / Maya_MatchTransforms.py
Last active August 20, 2016 15:56
Maya Match Transforms
import maya.cmds as cmds
import pymel.core as pm
def matchXfos():
# get selection
sel = pm.ls(selection=True)
if len(sel) < 2:
@EricTRocks
EricTRocks / ETQuickRenamer.py
Last active July 27, 2021 12:34
Simple Object Renamer Script / UI for Maya
import pymel.core as pm
def rename(cmpNameField, cmpLocationField, nameField, typeField):
sel = pm.ls(selection=True)
# Get Values of Fields
cmpName = pm.textField(cmpNameField, query=True, text=True)
cmpLocation = pm.optionMenu(cmpLocationField, query=True, value=True)
objName = pm.textField(nameField, query=True, text=True)
objType = pm.optionMenu(typeField, query=True, value=True)
@EricTRocks
EricTRocks / htmlColorsToRGB.py
Last active August 5, 2016 19:43
Convert HTML Colors to RGB float values
from decimal import Decimal, ROUND_DOWN
import json
# Base code from
# http://stackoverflow.com/questions/4296249/how-do-i-convert-a-hex-triplet-to-an-rgb-tuple-and-back
# Code by martineau
_NUMERALS = '0123456789abcdefABCDEF'
_HEXDEC = {v: int(v, 16) for v in (x+y for x in _NUMERALS for y in _NUMERALS)}
LOWERCASE, UPPERCASE = 'x', 'X'