def appendMayaMenu(self, path):
'''
Add tools to the maya menus
'''
menuLabel = labelFromPath(path)
formatLabel = menuLabel.replace(' ','').lower()
menuItemArray = mc.menu(self.mainMenus[formatLabel], query=True, itemArray=True)
#if this menu hasn't been built yet, run the post menu command to build it
#that took a long time to figure out.
if not menuItemArray:
if self.verbose:
print 'pre-building menu: ',menuLabel
pmc = mc.menu(self.mainMenus[formatLabel], query=True, postMenuCommand=True)
if pmc:
mm.eval(pmc)
menuItemArray = mc.menu(self.mainMenus[formatLabel], query=True, itemArray=True)
#get all the menu items in the menu
menuItems = dict()
for each in menuItemArray:
eachLabel = mc.menuItem(each, query=True, label=True)
menuItems[eachLabel] = each
subItems = [posixpath.join(path,x) for x in os.listdir(path) if (x.endswith('.py') or x.endswith('.mel')) and x != '__init__.py']
if subItems:
for path in subItems:
tool = Tool(path)
self.classifyTool(tool)
if not tool.errors:
tool.createMenuItem(parent=self.mainMenus[formatLabel], labelPrefix=MENU_ITEM_PREFIX+' ', italicized=True)
评论列表
文章目录