Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.2 kB
1
Indexable
Never
try:
    #ThirdParty toolbar rebuild
    upper = toolbar.addMenu("3rdParty", "AllPlugins.png")

    menus = ['Neat Video', 'ThirdParty', 'Peregrine', 'VideoCopilot', 'Sapphire', 'FurnaceCore', 'CaraVR', 'Spin Tools', '3DE4','Higx Tools', 'KeenTools', 'Ocula']

    for menu in menus:
        try:
            submenus = []
            #add Menu to upper menu
            currentMenu = upper.addMenu(menu)

            for item in toolbar.menu(menu).items():
                try:
                    #test if item a menu
                    test = item.script()
                    #add items that are not menus
                    currentMenu.addCommand( item.name(), item.script(), item.icon())
                except:
                    if item.name() != '':
                        submenu = currentMenu.addMenu(item.name())
                        submenus.append(submenu)

            #add items in submenus
            for submenu in submenus:
                for item in toolbar.menu(menu+'/'+submenu.name()).items():
                    try:
                        submenu.addCommand( item.name(), item.script(), item.icon())
                    except:
                       pass
            toolbar.removeItem(menu)
        except:
            pass

    #show menu rebuild
    try:
        show = os.getenv("JOB")
        orig = toolbar.menu(show)
        icon = "/usr/people/%s/.nuke/MPC/icons/%s.png" % (os.getenv("USER"), show)

        if os.path.isfile(icon):
            MI = []
            #collect items in order
            for item in orig.items():
                if str(type(item)) == "<type 'Menu'>":
                   MI.append(show + '/' + item.name())
                else:
                    try:
                        MI.append([show + '/' + item.name(), item.script(), item.icon()])
                    except:
                        pass

            for item in MI:
                if type(item) is str:
                    for sub in toolbar.menu(item).items():
                        if str(type(sub)) == "<type 'Menu'>":
                           MI.append(item + '/' + sub.name())
                        else:
                            MI.append([item + '/' + sub.name(), sub.script(), sub.icon()])

            #delete original menu
            toolbar.removeItem(show)

            #recreate Menu items
            upper = toolbar.addMenu(show, icon)

            for item in MI:
                if type(item) is str:
                    toolbar.addMenu(item)
                else:
                    toolbar.addCommand( item[0], item[1], item[2] )
    except:
        pass

    #remove menubar items
    try:
        pass
    except:
        pass

    #legacy toolbar
    try:
        import inspect
        from mpc.nuke.compGizmos.legacyStatistics import statistics as _statistics

        legacyString = inspect.getsource(mpc.nuke.compGizmos._core.menu._legacyGizmos).replace('legacyToolBar = toolBar.addMenu("Legacy"', 'legacyToolBar = toolBar.addMenu("MPC/Legacy"').replace('def _legacyGizmos(nuke):', 'if True:')

        exec(legacyString)
        toolbar.removeItem('Legacy')
    except:
        pass
except:
    pass