Skip to content

Instantly share code, notes, and snippets.

import maya.OpenMayaUI as omUI
import maya.cmds as cmds
import pymel.core as pm
qtVersion = pm.about(qtVersion=True)
if int(qtVersion.split('.')[0]) < 5:
from PySide.QtGui import *
from PySide.QtCore import *
# from pysideuic import *
from shiboken import wrapInstance
else:
import maya.cmds as cmds
def getSelectedLayers():
sel = []
for each in cmds.ls(type='animLayer'):
if cmds.animLayer(each, query=True, selected=True):
sel.append(each)
return sel
def toggleMuteLayer(layers):
@tb-animator
tb-animator / toggle integer snap
Created February 13, 2020 22:27
toggles graph editor integer snap and updates the button state
import maya.cmds as cmds
graphEd = 'graphEditor1GraphEd'
states=["none", "integer"]
state = cmds.animCurveEditor(graphEd, query=True, snapTime=True)
cmds.animCurveEditor(graphEd, edit=True, snapTime=states[not states.index(state)])
cmds.iconTextCheckBox('timeSnapButton', edit=True, value=not states.index(state))
import maya.mel as mel
import maya.cmds as cmds
'''
Quickly scale your selected keys or entire animation curves by -1, if you have keys selected in the graphEditor, they will all be scaled.
If no keys are selected, the currently highlighted channels in the channelbox will be flipped
'''
gChannelBoxName = mel.eval('$temp=$gChannelBoxName')
selection = cmds.ls(sl=True)
import maya.cmds as cmds
'''
quick and dirty graph editor collape toggle tool
'''
def toggleDockedGraphEd():
GraphEdWindow = None
state = False
if cmds.animCurveEditor('graphEditor1GraphEd', query=True, exists=True):
graphEdParent = cmds.animCurveEditor( 'graphEditor1GraphEd', query=True, panel=True )
if cmds.panel(graphEdParent, query=True, exists=True):
########################################################
# modification of the regular timeline drag for maya #
# by Tom Bailey - [email protected] #
# only works for 'film' 24 fps #
# just run this in python, then click+drag on your #
# timeline, alt+drag will smoothly scrub with no snap #
# ctrl+drag will retime the timeline to snap to every #
# 4 frames (6fps @ 24 fps) #
########################################################
import maya.mel
import pymel.core as pm
def beginDrag(*args):
mods = pm.getModifiers()
update = pm.timeControl( aPlayBackSliderPython, query=True, globalTime=True)
print update
if (mods & 1) > 0: print ' Shift'
if (mods & 2) > 0: print ' CapsLock'
if (mods & 4) > 0: print ' Ctrl'
import pymel.core as pm
def select_keyed_objs():
# empty list for our keyed objects to go in
keyed_objects = []
# loop over all objects in the scene (transform as mask to ignore animcurves etc)
for obj in pm.ls(type='transform'):
# check the keyframe count on the object
if pm.keyframe(obj, query=True, keyframeCount=True):
# if it's keyed, append it to our list
fonts = cmds.fontDialog(FontList=True)
print fonts
@tb-animator
tb-animator / pathcheck.py
Created October 7, 2015 21:56
check your python script paths
import sys
paths = sys.path
for p in paths:
print p