Skip to content

Instantly share code, notes, and snippets.

View splinecraft's full-sized avatar

Eric Luhta splinecraft

  • Vancouver, BC
View GitHub Profile
import os
filepath = r'E:/test_folder/'
os.chdir(filepath)
# make all filenames lowercase
for file in os.listdir(os.getcwd()):
name = file.lower()
os.rename(file, name)
helper = MaxPlus.Factory.CreateHelperObject(MaxPlus.ClassIds.Point)
helper_node = MaxPlus.Factory.CreateNode(helper)
MaxPlus.INode.SetBoneNodeOnOff(helper_node, True, 0) # Bone On
MaxPlus.INode.SetBoneAutoAlign(node, False) # Auto-Align off
MaxPlus.INode.SetBoneScaleType(node, 0) # Stretch: None
@splinecraft
splinecraft / swap_views
Last active December 22, 2017 00:54
swap ge and persp views
import maya.cmds as cmds
persp = cmds.getPanel(withLabel='Persp View')
ge = cmds.getPanel(withLabel='Graph Editor')
if cmds.getPanel(withFocus=True) == persp:
cmds.panel(persp, edit=True, replacePanel=ge)
if cmds.getPanel(withFocus=True) == ge:
cmds.panel(ge, edit=True, replacePanel=persp)
@splinecraft
splinecraft / unhide_joints
Created September 28, 2017 00:02
unhide joints
for node in pm.selected():
if node.nodeType() in ["joint"]:
if node.drawStyle.get() is 0:
node.drawStyle.set(2)
else:
node.drawStyle.set(0)
import pymel.core as pm
"""
To use:
Select a control on the source and then a control on the destination
Run the copy command
Select controls of the source to be copied
Run the paste command
import maya.cmds as mc
selection = mc.ls(sl=1)
toSelect = []
for item in selection:
constraint = mc.listConnections( item+'.parentInverseMatrix[0]', d=1, s=0,type='constraint')
if constraint:
constraint = constraint[0]
src = mc.listConnections(constraint+'.target[0].targetParentMatrix', d=0, s=1)
if src:
toSelect.extend(src)
@splinecraft
splinecraft / select_ctrls_in_animlayer.py
Last active September 30, 2017 20:04
select objects in anim layer
import pymel.core as pm
anim_layer_editor = 'AnimLayerTabanimLayerEditor'
current_anim_layers = pm.treeView(anim_layer_editor, q=True, si=True)
pm.mel.layerEditorSelectObjectAnimLayer(current_anim_layers)
@splinecraft
splinecraft / create_locs.py
Created July 20, 2017 23:24
create locators at selected control locations
import pymel.core as pm
from el_anim_utilities import anim_util as anim
selection = pm.ls(sl=True)
for sel in selection:
coord = pm.xform(sel, q=True, ws=True, rotatePivot=True)
loc = pm.spaceLocator(name='{}_loc'.format(sel))
pm.xform(loc, s=(40, 40, 40), t=coord)
anim.set_color(loc, 17)
@splinecraft
splinecraft / anim_util.py
Last active September 30, 2017 20:06
anim_util work
import pymel.core as pm
import maya.mel as mel
import maya.cmds as cmds
CORE_ATTRIBUTES = {'rx': 'rotateX',
'ry': 'rotateY',
'rz': 'rotateZ',
'tx': 'translateX',
'ty': 'translateY',
'tz': 'translateZ'
@splinecraft
splinecraft / curve_copy.py
Last active September 30, 2017 20:07
curve copy work
import pymel.core as pm
import collections
import anim_util as au
reload(au)
class AnimCurve:
"""Stores all data of an animation curve for copying/rebuilding"""