mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
add shader definition item to menu
This commit is contained in:
parent
e8066f072e
commit
7948820108
3 changed files with 19 additions and 36 deletions
6
openpype/hosts/maya/api/commands.py
Normal file
6
openpype/hosts/maya/api/commands.py
Normal file
|
|
@ -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
|
||||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue