From 49aa5da7fb00bf13ab859c74a19229565fcd97a2 Mon Sep 17 00:00:00 2001 From: Yi Date: Wed, 17 Jan 2018 17:51:39 -0500 Subject: [PATCH] Create reference using relative path instead of absolute path in Maya --- hooks/tk-maya_actions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hooks/tk-maya_actions.py b/hooks/tk-maya_actions.py index 033c6ddc..dcdc4769 100644 --- a/hooks/tk-maya_actions.py +++ b/hooks/tk-maya_actions.py @@ -192,8 +192,11 @@ def _create_reference(self, path, sg_publish_data): namespace = "%s %s" % (sg_publish_data.get("entity").get("name"), sg_publish_data.get("name")) namespace = namespace.replace(" ", "_") - pm.system.createReference(path, - loadReferenceDepth= "all", + # create reference using relative path instead of absolute path + current_path = cmds.file(q=True, sn=True) + relative_path = os.path.relpath(path, os.path.dirname(current_path)) + pm.system.createReference(relative_path, + loadReferenceDepth="all", mergeNamespacesOnClash=False, namespace=namespace)