diff --git a/openpype/hosts/maya/api/commands.py b/openpype/hosts/maya/api/commands.py new file mode 100644 index 0000000000..cbd8ec57f8 --- /dev/null +++ b/openpype/hosts/maya/api/commands.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +"""OpenPype script commands to be used directly in Maya.""" + +def edit_shader_definitions(): + print("Editing shader definitions...") + pass \ No newline at end of file diff --git a/openpype/hosts/maya/api/menu.py b/openpype/hosts/maya/api/menu.py index 5e036b8e0c..a8812210a5 100644 --- a/openpype/hosts/maya/api/menu.py +++ b/openpype/hosts/maya/api/menu.py @@ -6,9 +6,11 @@ from avalon.vendor.Qt import QtWidgets, QtGui from avalon.maya import pipeline from openpype.api import BuildWorkfile import maya.cmds as cmds +from openpype.settings import get_project_settings self = sys.modules[__name__] -self._menu = os.environ.get("AVALON_LABEL") +project_settings = get_project_settings(os.getenv("AVALON_PROJECT")) +self._menu = project_settings["maya"]["scriptsmenu"]["name"] log = logging.getLogger(__name__) @@ -55,34 +57,6 @@ def deferred(): 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() @@ -100,8 +74,7 @@ def deferred(): return # load configuration of custom menu - config_path = os.path.join(os.path.dirname(__file__), "menu.json") - config = scriptsmenu.load_configuration(config_path) + config = project_settings["maya"]["scriptsmenu"]["definition"] # run the launcher for Maya menu studio_menu = launchformaya.main( diff --git a/openpype/settings/defaults/project_settings/maya.json b/openpype/settings/defaults/project_settings/maya.json index 0375eb42d5..e3f0a86c27 100644 --- a/openpype/settings/defaults/project_settings/maya.json +++ b/openpype/settings/defaults/project_settings/maya.json @@ -10,12 +10,16 @@ "scriptsmenu": { "name": "OpenPype Tools", "definition": [ - { + { "type": "action", - "command": "$OPENPYPE_SCRIPTS\\others\\save_scene_incremental.py", - "sourcetype": "file", - "title": "# Version Up", - "tooltip": "Incremental save with a specific format" + "command": "import openpype.hosts.maya.api.commands as op_cmds; op_cmds.edit_shader_definitions()", + "sourcetype": "python", + "title": "Edit shader name definitions", + "tooltip": "Edit shader name definitions used in validation and renaming.", + "tags": [ + "pipeline", + "shader" + ] } ] },