Skip to content

Instantly share code, notes, and snippets.

View splinecraft's full-sized avatar

Eric Luhta splinecraft

  • Vancouver, BC
View GitHub Profile
import pymel.core as pm
curves = pm.keyframe(q=True, sl=True, name=True)
for curve in curves:
key_vals = pm.keyframe(curve, q=True, vc=True)
start_val = key_vals[0]
pm.keyframe(curve, e=True, vc=start_val*-1, relative=True)
import maya.cmds as cmds
import collections
def getAllLayers():
rootLayer = cmds.animLayer(q=True, r=True)
if rootLayer:
def search(layer, depth=0):
children = cmds.animLayer(layer, q=True, c=True)
if children:
import pymel.core as pm
from anim_utilities import anim_util
selection = pm.selected()
pm.refresh(suspend=True)
pm.bakeResults(selection, time=anim_util.get_playback_range())
pm.delete(staticChannels=True)
pm.filterCurve(selection)
pm.refresh(suspend=False)
@splinecraft
splinecraft / toggleMayaWindows
Created October 24, 2019 22:27
from animstate discord
import maya.cmds as mc
import maya.mel as mm
def toggleMayaWindows(key):
# use toggleMayaWindows("GraphEditor"), toggleMayaWindows("DopeSheet"), etc
windDict = {"DopeSheet": ["dopeSheetPanel1Window", "DopeSheetEditor"],
"GraphEditor": ["graphEditor1Window", "GraphEditor"],
"TraxEditor": ["clipEditorPanel1Window", "CharacterAnimationEditor"],
"HyperShade": ["hyperShadePanel1Window", "HypershadeWindow"],
"Outliner": ["outlinerPanel1Window", "OutlinerWindow"],
import maya.cmds as cmds
cursel = cmds.ls( sl=True )
for obj in cursel:
newname = obj.lower()
cmds.rename( obj, newname )
@splinecraft
splinecraft / invert_key_vals
Created January 9, 2019 01:35
inverts selected keyframe values (* -1)
import maya.cmds as cmds
curves = cmds.keyframe(q=True, sl=True, n=True)
if curves:
for curve in curves:
key_times = cmds.keyframe(curve, q=True, sl=True, tc=True)
key_vals = cmds.keyframe(curve, q=True, sl=True, vc=True)
for i, frame in enumerate(key_times):
cmds.keyframe(curve, e=True, time=(frame,frame), absolute=True, vc=(key_vals[i]*-1))
@splinecraft
splinecraft / mirror_cam
Created December 5, 2018 18:27
duplicates current cam and flips it horizontally. from https://pastecode.xyz/view/b7c34dda#L19
import maya.cmds as mc
def createMirrorCam(currentCam):
mirrorCam_grp = mc.group(empty=True,n="mirrorCam_grp")
mc.addAttr(mirrorCam_grp, ln="notes", dt="string", sn="nts")
mc.setAttr("%s.notes"%mirrorCam_grp, currentCam,type="string")
mirrorCam = mc.duplicate (currentCam,n="mirrorCam")
camPos = mc.xform(mirrorCam[0], ws=1, t=1, q=1)
camRot = mc.xform(mirrorCam[0], ws=1, ro=1, q=1)
mc.xform(mirrorCam_grp, ws=1, t=(camPos[0], camPos[1], camPos[2]),ro=(camRot[0], camRot[1], camRot[2]))
import maya.cmds as cmds
pb_speed = cmds.playbackOptions(q=True, playbackSpeed=True)
if pb_speed == 1:
cmds.playbackOptions(e=True, playbackSpeed=0.5)
print('Playback Speed: 0.5' + '\n')
elif pb_speed == 0.5:
cmds.playbackOptions(e=True, playbackSpeed=1)
print('Playback Speed: 1.0' + '\n')
@splinecraft
splinecraft / remove_scale_compensate
Created July 14, 2018 20:06
Are your characters doing weird scale things in Unity coming from Maya? It's probably the Segment Scale Compensate on joints causing your problems. Segment Scale Compensate is on by default every time you make a new joint. You can learn more about Se
{
string $selected[] = `ls -type joint`;
select -r $selected;
}
string $sel[] = `ls -sl`;
string $singleJnt;
for ($singleJnt in $sel)
{
setAttr ($singleJnt + ".segmentScaleCompensate") 0;
import pymxs
rt = pymxs.runtime
def delete_similar_named_objs(in_name):
rt.select(rt.objects)
to_delete = []
for s in rt.selection:
if in_name in s.name:
to_delete.append(s) # using rt.delete(s) doesn't get all the objects for some reason