1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| import maya.cmds as cmds
import os
from functools import partial
import maya.mel as mel
widgets = {}
def UI():
if cmds.window("rigtool", exists = True):
cmds.deleteUI("rigtool")
widgets["window"] = cmds.window("rigtool", mnb = False, mxb = False, title = (28 * ("-")+ "rigtool" + 28 * ("-")))
widgets["scrollLayout"] = cmds.scrollLayout(hst = 0)
widgets["mainLayout"] = cmds.columnLayout(adj = True, parent = widgets["scrollLayout"])
#find icons and create symbol button for each icon ( largeur * hauteur)
populateIcons()
cmds.showWindow(widgets["window"])
cmds.window(widgets["window"], edit = True, w = 530, h = 610, sizeable = True)
def populateIcons():
IconPath = cmds.internalVar(upd = True) + "\icons\elocius\rigtool/"
icons = os.listdir(IconPath)
categories = []
for icon in icons:
categoryName = icon.partition("_")[0]
categories.append(categoryName)
categoryNames = list(set(categories))
for name in categoryNames:
#create a frameLayout
widgets[(name + "_frameLayout")] = cmds.frameLayout(label = name, collapsable = True, parent = widgets["mainLayout"])
widgets[(name + "_mainLayout")] = cmds.rowColumnLayout(nc = 6, parent = widgets[name + "_frameLayout"])
for icon in icons:
niceName = icon.partition(".")[0]
category = icon.partition("__")[0]
command = icon.partition("__")[2].partition(".")[0] #exemple : nodeeditor
widgets[(niceName + "_button")] = cmds.symbolButton(w = 85, h = 45, image = (IconPath + icon), parent = widgets[(category +"_mainLayout")], c = partial(runMethod, command))
def runMethod(method, *args):
exec(method + "()")
#---------------------------------------------------------------------------------CREATE THE MEL CALL COMMANDS----------------------------------------------------------------------------
#-------------OUTLINE----------------------
def geo__addGeo():
mel.eval("CreateEmptyGroup;")
cmds.showWindow(widgets["window"]) |
Partager