@@ -39,6 +39,7 @@ class BaseCommand(OpenMayaMPx.MPxCommand, LoggerMixin):
39
39
def __init__ (self ):
40
40
OpenMayaMPx .MPxCommand .__init__ (self )
41
41
LoggerMixin .__init__ (self )
42
+ self ._exportSet = "UnityFbxExportSet"
42
43
43
44
def __del__ (self ):
44
45
LoggerMixin .__del__ (self )
@@ -84,9 +85,28 @@ def scriptCmd(cls):
84
85
return
85
86
86
87
def doIt (self , args ):
88
+ # Gather everything that is in the scene
89
+ origItemsInScene = maya .cmds .ls (tr = True , o = True , r = True )
90
+
87
91
strCmd = 'Import'
88
92
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 )
90
110
91
111
@classmethod
92
112
def invoke (cls ):
0 commit comments