Skip to content

Commit c616a0a

Browse files
authored
SG-13274 Maya hooks updated to work with Python 3. (#83)
The Maya hooks have been updated to work with Python 3. This includes converting from using PyMEL.
1 parent 9189ad6 commit c616a0a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

hooks/tk-maya_actions.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
import glob
1616
import os
1717
import re
18-
import pymel.core as pm
1918
import maya.cmds as cmds
2019
import maya.mel as mel
2120
import sgtk
2221

22+
from tank_vendor import six
23+
2324
HookBaseClass = sgtk.get_hook_baseclass()
2425

2526

@@ -178,7 +179,7 @@ def execute_action(self, name, params, sg_publish_data):
178179
# resolve path
179180
# toolkit uses utf-8 encoded strings internally and Maya API expects unicode
180181
# so convert the path to ensure filenames containing complex characters are supported
181-
path = self.get_publish_path(sg_publish_data).decode("utf-8")
182+
path = six.ensure_str(self.get_publish_path(sg_publish_data))
182183

183184
if name == "reference":
184185
self._create_reference(path, sg_publish_data)
@@ -217,8 +218,10 @@ def _create_reference(self, path, sg_publish_data):
217218
)
218219
namespace = namespace.replace(" ", "_")
219220

220-
pm.system.createReference(
221+
# Now create the reference object in Maya.
222+
cmds.file(
221223
path,
224+
reference=True,
222225
loadReferenceDepth="all",
223226
mergeNamespacesOnClash=False,
224227
namespace=namespace,

0 commit comments

Comments
 (0)