From ed730c02e64a7e5189b09598b89dec545e245270 Mon Sep 17 00:00:00 2001 From: aardschok Date: Tue, 4 Jul 2017 15:20:06 +0200 Subject: [PATCH] implemented scripts menu to launcher --- colorbleed/__init__.py | 2 +- colorbleed/maya/menu.json | 61 ++++++++++++ colorbleed/maya/menu.py | 98 +++++++++++-------- ...ode_ids.py => validate_unique_node_ids.py} | 2 +- 4 files changed, 121 insertions(+), 42 deletions(-) create mode 100644 colorbleed/maya/menu.json rename colorbleed/plugins/maya/publish/{_validate_unique_node_ids.py => validate_unique_node_ids.py} (98%) diff --git a/colorbleed/__init__.py b/colorbleed/__init__.py index a6d0890f25..a158fcbee9 100644 --- a/colorbleed/__init__.py +++ b/colorbleed/__init__.py @@ -14,4 +14,4 @@ def install(): def uninstall(): - pyblish.deregister_plugin_path(PUBLISH_PATH) \ No newline at end of file + pyblish.deregister_plugin_path(PUBLISH_PATH) diff --git a/colorbleed/maya/menu.json b/colorbleed/maya/menu.json new file mode 100644 index 0000000000..1918163f97 --- /dev/null +++ b/colorbleed/maya/menu.json @@ -0,0 +1,61 @@ +{"Animation": [{"title" : "Script A", + "tooltip": "Script A", + "command": "$SCRIPTMENU/script_a.py", + "sourcetype": "file", + "tags": ["test", "script", "cluster"], + "icon": "$SCRIPTMENU/resources/script_a.png", + "label": "SCR A"}, + {"title" : "Script B", + "tooltip": "Run script B", + "command": "$SCRIPTMENU/script_b.py", + "sourcetype": "file", + "tags": ["test", "script", "curves"]}, + {"title" : "Script C", + "tooltip": "Run script C", + "command": "$SCRIPTMENU/script_c.py", + "sourcetype": "file", + "tags": ["test", "script", "joints"], + "icon": ""} + ], + +"Modeling": [{"title" : "Script A", + "tooltip": "Run script A", + "command": "$SCRIPTMENU/script_a.py", + "sourcetype": "file", + "tags": ["test", "script", "model", "blendshapes"]}, + {"title" : "Script B", + "tooltip": "Run script B", + "command": "$SCRIPTMENU/script_b.py", + "sourcetype": "file", + "tags": ["test", "script", "normals", "model"]}, + {"title" : "Script C", + "tooltip": "Run script C", + "command": "$SCRIPTMENU/script_c.py", + "sourcetype": "file", + "tags": ["math", "power", "sum"]} + ], + +"Rigging": [{"title" : "Script A", + "tooltip": "Run script A", + "command": "$SCRIPTMENU/script_a.py", + "sourcetype": "file", + "tags": ["test", "tool", "rig", "skeleton"]}, + {"title" : "Script B", + "tooltip": "Run script A", + "command": "$SCRIPTMENU/script_b.py", + "sourcetype": "file", + "tags": ["test", "script", "cloth", "rig", "setup"]}, + {"title" : "Script C", + "tooltip": "Run script C", + "command": "$SCRIPTMENU/script_c.py", + "sourcetype": "file", + "tags": ["test", "script", "approval"]} + ], + +"MEL": [{"title" : "Create cube", + "tooltip": "Launch character rigging tool", + "command": "polyCube -w 1 -h 1 -d 1;", + "sourcetype": "mel", + "tags": ["test", "script", "mel"]} + ] +} \ No newline at end of file diff --git a/colorbleed/maya/menu.py b/colorbleed/maya/menu.py index 07a9ba81ce..f72dc07ed9 100644 --- a/colorbleed/maya/menu.py +++ b/colorbleed/maya/menu.py @@ -1,62 +1,80 @@ import sys -from maya import cmds + from avalon.vendor.Qt import QtWidgets, QtCore self = sys.modules[__name__] self._menu = "colorbleed" -self._parent = { - widget.objectName(): widget - for widget in QtWidgets.QApplication.topLevelWidgets() -}.get("MayaWindow") +self._parent = {widget.objectName(): widget for widget in + QtWidgets.QApplication.topLevelWidgets()}.get("MayaWindow") def install(): - from . import interactive + # from . import interactive uninstall() def deferred(): - cmds.menu(self._menu, - label="Colorbleed", - tearOff=True, - parent="MayaWindow") - # Modeling sub-menu - cmds.menuItem("Modeling", - label="Modeling", - tearOff=True, - subMenu=True, - parent=self._menu) + import site + import os - cmds.menuItem("Combine", command=interactive.combine) + # todo: replace path with server / library path + site.addsitedir("C:\Users\User\Documents\development\scriptsmenu\python") - # Rigging sub-menu - cmds.menuItem("Rigging", - label="Rigging", - tearOff=True, - subMenu=True, - parent=self._menu) + from scriptsmenu import launchformaya + import scriptsmenu.scriptsmenu as menu - cmds.menuItem("Auto Connect", command=interactive.auto_connect) - cmds.menuItem("Clone (Local)", command=interactive.clone_localspace) - cmds.menuItem("Clone (World)", command=interactive.clone_worldspace) - cmds.menuItem("Clone (Special)", command=interactive.clone_special) - cmds.menuItem("Create Follicle", command=interactive.follicle) + # load configuration of custon menu + config_path = os.path.join(os.path.dirname(__file__), "menu.json") + config = menu.load_configuration(config_path) - # Animation sub-menu - cmds.menuItem("Animation", - label="Animation", - tearOff=True, - subMenu=True, - parent=self._menu) + # create menu in appliction + cb_menu = launchformaya.main(title=self._menu, parent=self._parent) - cmds.menuItem("Set Defaults", command=interactive.set_defaults) + # apply configuration + menu.load_from_configuration(cb_menu, config) - cmds.setParent("..", menu=True) - - cmds.menuItem(divider=True) - - cmds.menuItem("Auto Connect", command=interactive.auto_connect_assets) + # cmds.menu(self._menu, + # label=self._menu.capitalize(), + # tearOff=True, + # parent="MayaWindow") + # + # # Modeling sub-menu + # cmds.menuItem("Modeling", + # label="Modeling", + # tearOff=True, + # subMenu=True, + # parent=self._menu) + # + # cmds.menuItem("Combine", command=interactive.combine) + # + # # Rigging sub-menu + # cmds.menuItem("Rigging", + # label="Rigging", + # tearOff=True, + # subMenu=True, + # parent=self._menu) + # + # cmds.menuItem("Auto Connect", command=interactive.auto_connect) + # cmds.menuItem("Clone (Local)", command=interactive.clone_localspace) + # cmds.menuItem("Clone (World)", command=interactive.clone_worldspace) + # cmds.menuItem("Clone (Special)", command=interactive.clone_special) + # cmds.menuItem("Create Follicle", command=interactive.follicle) + # + # # Animation sub-menu + # cmds.menuItem("Animation", + # label="Animation", + # tearOff=True, + # subMenu=True, + # parent=self._menu) + # + # cmds.menuItem("Set Defaults", command=interactive.set_defaults) + # + # cmds.setParent("..", menu=True) + # + # cmds.menuItem(divider=True) + # + # cmds.menuItem("Auto Connect", command=interactive.auto_connect_assets) # Allow time for uninstallation to finish. QtCore.QTimer.singleShot(100, deferred) diff --git a/colorbleed/plugins/maya/publish/_validate_unique_node_ids.py b/colorbleed/plugins/maya/publish/validate_unique_node_ids.py similarity index 98% rename from colorbleed/plugins/maya/publish/_validate_unique_node_ids.py rename to colorbleed/plugins/maya/publish/validate_unique_node_ids.py index d7453a3a4c..616cabfdc4 100644 --- a/colorbleed/plugins/maya/publish/_validate_unique_node_ids.py +++ b/colorbleed/plugins/maya/publish/validate_unique_node_ids.py @@ -18,7 +18,7 @@ class ValidateUniqueNodeIds(pyblish.api.InstancePlugin): import maya.cmds as cmds - uuid_attr = "mbId" + uuid_attr = "cbId" # Collect each id with their members from collections import defaultdict