def deferred(): def add_build_workfiles_item(): # Add build first workfile cmds.menuItem(divider=True, parent=pipeline._menu) cmds.menuItem("Build First Workfile", parent=pipeline._menu, command=lambda *args: BuildWorkfile().process()) log.info("Attempting to install scripts menu..") try: import scriptsmenu.launchformaya as launchformaya import scriptsmenu.scriptsmenu as scriptsmenu except ImportError: log.warning("Skipping studio.menu install, because " "'scriptsmenu' module seems unavailable.") add_build_workfiles_item() return # load configuration of custom menu config_path = os.path.join(os.path.dirname(__file__), "menu.json") config = scriptsmenu.load_configuration(config_path) # run the launcher for Maya menu studio_menu = launchformaya.main(title=self._menu.title(), objectName=self._menu) # apply configuration studio_menu.build_from_configuration(studio_menu, config)
def deferred(): import scriptsmenu.launchformaya as launchformaya import scriptsmenu.scriptsmenu as scriptsmenu log.info("Attempting to install ...") # load configuration of custom menu config_path = os.path.join(os.path.dirname(__file__), "menu.json") config = scriptsmenu.load_configuration(config_path) # run the launcher for Maya menu cb_menu = launchformaya.main(title=self._menu.title(), objectName=self._menu) # apply configuration cb_menu.build_from_configuration(cb_menu, config)
def deferred(): log.info("Attempting to install scripts menu..") try: import scriptsmenu.launchformaya as launchformaya import scriptsmenu.scriptsmenu as scriptsmenu except ImportError: log.warning("Skipping colorbleed.menu install, because " "'scriptsmenu' module seems unavailable.") return # load configuration of custom menu config_path = os.path.join(os.path.dirname(__file__), "menu.json") config = scriptsmenu.load_configuration(config_path) # run the launcher for Maya menu cb_menu = launchformaya.main(title=self._menu.title(), objectName=self._menu) # apply configuration cb_menu.build_from_configuration(cb_menu, config)
def deferred(): def add_build_workfiles_item(): # Add build first workfile cmds.menuItem(divider=True, parent=pipeline._menu) cmds.menuItem( "Build First Workfile", parent=pipeline._menu, command=lambda *args: BuildWorkfile().process() ) def add_look_assigner_item(): import mayalookassigner cmds.menuItem( "Look assigner", parent=pipeline._menu, command=lambda *args: mayalookassigner.show() ) def modify_workfiles(): from pype.tools import workfiles def launch_workfiles_app(*_args, **_kwargs): workfiles.show( os.path.join( cmds.workspace(query=True, rootDirectory=True), cmds.workspace(fileRuleEntry="scene") ), parent=pipeline._parent ) # Find the pipeline menu top_menu = _get_menu(pipeline._menu) # Try to find workfile tool action in the menu workfile_action = None for action in top_menu.actions(): if action.text() == "Work Files": workfile_action = action break # Add at the top of menu if "Work Files" action was not found after_action = "" if workfile_action: # Use action's object name for `insertAfter` argument after_action = workfile_action.objectName() # Insert action to menu cmds.menuItem( "Work Files", parent=pipeline._menu, command=launch_workfiles_app, insertAfter=after_action ) # Remove replaced action if workfile_action: top_menu.removeAction(workfile_action) log.info("Attempting to install scripts menu..") add_build_workfiles_item() add_look_assigner_item() modify_workfiles() try: import scriptsmenu.launchformaya as launchformaya import scriptsmenu.scriptsmenu as scriptsmenu except ImportError: log.warning( "Skipping studio.menu install, because " "'scriptsmenu' module seems unavailable." ) return # load configuration of custom menu config_path = os.path.join(os.path.dirname(__file__), "menu.json") config = scriptsmenu.load_configuration(config_path) # run the launcher for Maya menu studio_menu = launchformaya.main( title=self._menu.title(), objectName=self._menu ) # apply configuration studio_menu.build_from_configuration(studio_menu, config)
import os import sys from Qt import QtWidgets, QtGui from scriptsmenu import ScriptsMenu from scriptsmenu.scriptsmenu import ( load_configuration, build_from_configuration ) # set the example evironment variable os.environ["SCRIPTMENU"] = os.path.dirname(__file__) config = os.path.expandvars(r"$SCRIPTMENU/sample_configuration_a.json") config = load_configuration(config) # parse the .json file app = QtWidgets.QApplication(sys.argv) menu = ScriptsMenu(title="Scripts", parent=None) # populate the menu using the configuration JSON file. menu.build_from_configuration(menu, config) menu.exec_(QtGui.QCursor.pos()) app.exec_()