Skip to content

Commit 065ccf2

Browse files
committed
on import create a set containing what was imported
1 parent 3065e50 commit 065ccf2

File tree

1 file changed

+21
-1
lines changed
  • Assets/Integrations/Autodesk/maya2017/scripts/unityOneClick

1 file changed

+21
-1
lines changed

Assets/Integrations/Autodesk/maya2017/scripts/unityOneClick/commands.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class BaseCommand(OpenMayaMPx.MPxCommand, LoggerMixin):
3939
def __init__(self):
4040
OpenMayaMPx.MPxCommand.__init__(self)
4141
LoggerMixin.__init__(self)
42+
self._exportSet = "UnityFbxExportSet"
4243

4344
def __del__(self):
4445
LoggerMixin.__del__(self)
@@ -84,9 +85,28 @@ def scriptCmd(cls):
8485
return
8586

8687
def doIt(self, args):
88+
# Gather everything that is in the scene
89+
origItemsInScene = maya.cmds.ls(tr=True, o=True, r=True)
90+
8791
strCmd = 'Import'
8892
self.displayDebug('doIt {0}'.format(strCmd))
89-
maya.mel.eval(strCmd)
93+
result = maya.cmds.Import()
94+
95+
# figure out what has been added after import
96+
itemsInScene = maya.cmds.ls(tr=True, o=True, r=True)
97+
newItems = list(set(itemsInScene) - set(origItemsInScene))
98+
99+
# Get or create the Unity Fbx Export Set
100+
allSets = maya.cmds.listSets(allSets=True)
101+
if self._exportSet in allSets:
102+
if maya.cmds.sets(self._exportSet, size=True, q=True) > 0:
103+
self.displayDebug('Set {0} is not empty, cannot update'.format(self._exportSet))
104+
return
105+
else:
106+
# couldn't find export set so create it
107+
maya.cmds.sets(name=self._exportSet)
108+
109+
maya.cmds.sets(newItems, add=self._exportSet)
90110

91111
@classmethod
92112
def invoke(cls):

0 commit comments

Comments
 (0)