Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Created by Don Campbell with guidence from Justin Isreal.
- # This tool will take prefixed ( currently hard coded to "qss") and
- # dynamically create a window and buttons to select the set and key avaiable
- # animation channels.
- # Possible updates window to input prefix and or window that simply puts all
- # user created quick select sets in their own window for easy activation.
- import maya.cmds as cmds
- from functools import partial
- def myfunc2(inst=None, thing=None, arg=None):
- # thing will be the button name
- label = cmds.button(thing, query=True, label=True)
- # look up the selection set from the button name
- quickSel = inst.buttons[thing]
- cmds.select(quickSel, replace=True)
- # used a manual KEY ALL because I was finding a
- # bug with the selection of the first button and
- # the channelBox not seeing any items in time
- for node in cmds.ls(sl=True, l=True):
- for attr in cmds.listAttr(node, r=True, w=True, k=True, v=True):
- cmds.setKeyframe('%s.%s' % (node, attr))
- class ui():
- def __init__(self, winName="winTheWindow"):
- self.winTitle = "The Window"
- self.winName = winName
- # save our dynamic buttons here with any meta data we want
- self.buttons = {}
- def create(self,setList):
- if cmds.window(self.winName, exists=True):
- cmds.deleteUI(self.winName)
- cmds.window(self.winName, title=self.winTitle)
- self.mainCol = cmds.columnLayout( adjustableColumn=True )
- for i in setList:
- name = "%s Key ALL" % i
- button = cmds.button(label=name)
- # pass the button name as the "thing"
- cmds.button(button, e=True, c=partial(myfunc2, self, button))
- # save our button in a dict, with the select set as the value
- self.buttons[button] = i
- cmds.showWindow( self.winName )
- cmds.window(self.winName, edit=True, widthHeight=[250,450])
- #define the prefix
- prefix = "qss"
- setnames = []
- #select all the object sets
- Slist = cmds.ls(sets = True)
- #loop through and append only the set names we want.
- for b in Slist:
- if b.startswith(prefix):
- print b
- setnames.append(b)
- # create the window
- inst = ui()
- inst.create(setnames)
Advertisement
Add Comment
Please, Sign In to add comment