ml_toolbox.py 文件源码

python
阅读 58 收藏 0 点赞 0 评论 0

项目:ml_tools 作者: morganloomis 项目源码 文件源码
def createMainMenus(self):

        #mayas main window menu:
        gMainWindow = mm.eval('$temp=$gMainWindow')
        #get all the menus that are children of the main menu
        mainWindowMenus = mc.window(gMainWindow, query=True, menuArray=True)
        #get the label for each of the menus
        #this will be matched against tool directories
        self.mainMenus = dict()
        for name in mainWindowMenus:
            label = mc.menu(name, query=True, label=True)
            #we need to make the label all lower case and no spaces, so we can match properly.
            formatLabel = label.replace(' ','').lower()
            self.mainMenus[formatLabel] = name

        mayaMenuDirectories = list()
        customMenuDirectories = list()

        for folder in os.listdir(self.menusPath):
            if folder.startswith('.'):
                continue

            toolDirectory = posixpath.join(self.menusPath,folder)

            #only directories for this first level
            if not os.path.isdir(toolDirectory):
                if not folder.startswith('__init__') and self.verbose:
                    print 'Root level file being ignored, move this to a sub-directory: ',toolDirectory
                continue

            menuLabel = labelFromPath(toolDirectory)
            formatLabel = menuLabel.replace(' ','').lower()

            if formatLabel in self.mainMenus and not self.mainMenus[formatLabel].startswith(MAIN_MENU_NAME_PREFIX):
                #maya menus
                mayaMenuDirectories.append(toolDirectory)
            else:
                #custom menu
                customMenuDirectories.append(toolDirectory)

        if mayaMenuDirectories:
            for d in mayaMenuDirectories:
                self.appendMayaMenu(d)

        if customMenuDirectories:
            for d in customMenuDirectories:
                self.createCustomMenu(d, parent=gMainWindow, mainMenu=True)

        self.setHotkeys()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号