From d5cdf2215666569cc716fe60e2ce5642542d556a Mon Sep 17 00:00:00 2001 From: aardschok Date: Mon, 25 Sep 2017 14:16:59 +0200 Subject: [PATCH 1/3] added explicit load for AbcImport / Export, moved function to lib, removed unused fuction --- colorbleed/maya/__init__.py | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/colorbleed/maya/__init__.py b/colorbleed/maya/__init__.py index d90957b7f5..b586027829 100644 --- a/colorbleed/maya/__init__.py +++ b/colorbleed/maya/__init__.py @@ -1,5 +1,4 @@ import os -import uuid from maya import cmds @@ -18,6 +17,7 @@ PUBLISH_PATH = os.path.join(PLUGINS_DIR, "maya", "publish") LOAD_PATH = os.path.join(PLUGINS_DIR, "maya", "load") CREATE_PATH = os.path.join(PLUGINS_DIR, "maya", "create") +LOAD_AT_START = ["AbcImport", "AbcExport"] # This is a temporary solution with the http.py clash with six.py # Maya has added paths to the PYTHONPATH which are redundant as @@ -73,6 +73,12 @@ def install(): menu.install() + # Add any needed plugins + for plugin in LOAD_AT_START: + if cmds.pluginInfo(plugin, query=True, loaded=True): + continue + cmds.loadPlugin(plugin, quiet=True) + print("Installing callbacks ... ") avalon.on("init", on_init) avalon.on("new", on_new) @@ -90,31 +96,6 @@ def uninstall(): menu.uninstall() -def _set_uuid(asset_id, node): - """Add cbId to `node` - Unless one already exists. - """ - - attr = "{0}.cbId".format(node) - if not cmds.attributeQuery("cbId", node=node, exists=True): - cmds.addAttr(node, longName="cbId", dataType="string") - _, uid = str(uuid.uuid4()).rsplit("-", 1) - cb_uid = "{}:{}".format(asset_id, uid) - - cmds.setAttr(attr, cb_uid, type="string") - - -def _copy_uuid(source, target): - - source_attr = "{0}.cbId".format(source) - target_attr = "{0}.cbId".format(target) - if not cmds.attributeQuery("cbId", node=target, exists=True): - cmds.addAttr(target, longName="cbId", dataType="string") - - attribute_value = cmds.getAttr(source_attr) - cmds.setAttr(target_attr, attribute_value, type="string") - - def on_init(_): avalon.logger.info("Running callback on init..") @@ -149,6 +130,5 @@ def on_save(_): projection={"_id": True}) # generate the ids - for node in nodes: - _set_uuid(str(asset_id["_id"]), node) + lib.set_id(str(asset_id["_id"]), node) From a73f529d039d92e7f0470d28a7dd94c94df3bcdd Mon Sep 17 00:00:00 2001 From: aardschok Date: Mon, 25 Sep 2017 14:17:47 +0200 Subject: [PATCH 2/3] Added set_id and remove_id --- colorbleed/maya/lib.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/colorbleed/maya/lib.py b/colorbleed/maya/lib.py index 3d231d050a..b22e5a3f5c 100644 --- a/colorbleed/maya/lib.py +++ b/colorbleed/maya/lib.py @@ -2,6 +2,8 @@ import re import os +import uuid + import bson import json import logging @@ -677,6 +679,30 @@ def get_id(node): return cmds.getAttr("{}.cbId".format(node)) +def set_id(asset_id, node): + """Add cbId to `node` unless one already exists. + + Args: + asset_id (str): the unique asset code from the database + node (str): the node to add the "cbId" on + + Returns: + None + """ + + attr = "{0}.cbId".format(node) + if not cmds.attributeQuery("cbId", node=node, exists=True): + cmds.addAttr(node, longName="cbId", dataType="string") + _, uid = str(uuid.uuid4()).rsplit("-", 1) + cb_uid = "{}:{}".format(asset_id, uid) + cmds.setAttr(attr, cb_uid, type="string") + + +def remove_id(node): + if cmds.attributeQuery("cbId", node=node, exists=True): + cmds.deleteAttr("{}.cbId".format(node)) + + def get_representation_file(representation, template=TEMPLATE): """ Rebuild the filepath of the representation's context From a2a10970d68c5d1f5ff8426c639de5597803d842 Mon Sep 17 00:00:00 2001 From: aardschok Date: Mon, 25 Sep 2017 14:18:16 +0200 Subject: [PATCH 3/3] added script for asset_id:uuid control --- colorbleed/maya/menu.json | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/colorbleed/maya/menu.json b/colorbleed/maya/menu.json index d9728c2245..eb26bb0f08 100644 --- a/colorbleed/maya/menu.json +++ b/colorbleed/maya/menu.json @@ -1545,6 +1545,14 @@ "title": "Remove User Defined Attributes", "tooltip": "" }, + { + "type": "action", + "command": "$COLORBLEED_SCRIPTS\\cleanup\\update_asset_id.py", + "sourcetype": "file", + "tags":["cleanup", "update", "database", "asset", "id"], + "title": "Update Asset ID", + "tooltip": "Will replace the Colorbleed ID with a new one (asset ID : Unique number)" + }, { "type": "action", "command": "$COLORBLEED_SCRIPTS\\cleanup\\removeUnknownNodes.py", @@ -1744,13 +1752,13 @@ }, { "type": "action", - "command": "$COLORBLEED_SCRIPTS\\cleanup\\", + "command": "$COLORBLEED_SCRIPTS\\others\\instanceLeafSmartTransform.py", "sourcetype": "file", "tags": ["others", "instance","leaf", "smart", "transform"], "title": "Instance Leaf Smart Transform", "tooltip": "" }, - { + { "type": "action", "command": "$COLORBLEED_SCRIPTS\\others\\instanceSmartTransform.py", "sourcetype": "file",