34
34
35
35
import os
36
36
37
- UNITY_FBX_FILE_PATH = None
38
- UNITY_FBX_FILE_NAME = None
37
+ # Global variables set on import, to be used for publishing.
38
+ # The variables are set in the afterImport function (a callback for OpenMaya.MSceneMessage.kAfterImport)
39
+ # in the importCmd class, and used by the publishCmd.doIt() function.
40
+ unity_fbx_file_path = None
41
+ unity_fbx_file_name = None
39
42
40
43
class BaseCommand (OpenMayaMPx .MPxCommand , LoggerMixin ):
41
44
"""
@@ -65,14 +68,12 @@ def loadUnityFbxExportSettings(self):
65
68
"""
66
69
Load the Export Settings from file
67
70
"""
68
- file = maya .cmds .optionVar (q = "UnityFbxExportSettings" )
69
- #unityProjectPath = maya.cmds.optionVar(q='UnityProject')
70
- #file = unityProjectPath + "/Integrations/Autodesk/maya2017/scripts/unityFbxExportSettings.mel"
71
- if not os .path .isfile (file ):
72
- maya .cmds .error ("Failed to find Unity Fbx Export Settings at: {0}" .format (file ))
71
+ fileName = maya .cmds .optionVar (q = "UnityFbxExportSettings" )
72
+ if not os .path .isfile (fileName ):
73
+ maya .cmds .error ("Failed to find Unity Fbx Export Settings at: {0}" .format (fileName ))
73
74
return False
74
75
75
- with open (file ) as f :
76
+ with open (fileName ) as f :
76
77
contents = f .read ()
77
78
78
79
maya .mel .eval (contents )
@@ -117,10 +118,10 @@ def beforeImport(self, retCode, file, clientData):
117
118
self ._tempName = file .resolvedName ()
118
119
119
120
def afterImport (self , * args , ** kwargs ):
120
- global UNITY_FBX_FILE_PATH
121
- global UNITY_FBX_FILE_NAME
122
- UNITY_FBX_FILE_PATH = self ._tempPath
123
- UNITY_FBX_FILE_NAME = self ._tempName
121
+ global unity_fbx_file_path
122
+ global unity_fbx_file_name
123
+ unity_fbx_file_path = self ._tempPath
124
+ unity_fbx_file_name = self ._tempName
124
125
125
126
def doIt (self , args ):
126
127
self .loadDependencies ()
@@ -133,7 +134,7 @@ def doIt(self, args):
133
134
134
135
# Gather everything that is in the scene
135
136
origItemsInScene = maya .cmds .ls (tr = True , o = True , r = True )
136
-
137
+
137
138
strCmd = 'Import'
138
139
self .displayDebug ('doIt {0}' .format (strCmd ))
139
140
result = maya .cmds .Import ()
@@ -275,10 +276,10 @@ def doIt(self, args):
275
276
if not self .loadUnityFbxExportSettings ():
276
277
return
277
278
278
- global UNITY_FBX_FILE_PATH
279
- global UNITY_FBX_FILE_NAME
280
- if UNITY_FBX_FILE_PATH and UNITY_FBX_FILE_NAME :
281
- strCmd = r'file -force -options "" -typ "FBX export" -pr -es "{0}{1}"' .format (UNITY_FBX_FILE_PATH , UNITY_FBX_FILE_NAME );
279
+ global unity_fbx_file_path
280
+ global unity_fbx_file_name
281
+ if unity_fbx_file_path and unity_fbx_file_name :
282
+ strCmd = r'file -force -options "" -typ "FBX export" -pr -es "{0}{1}"' .format (unity_fbx_file_path , unity_fbx_file_name );
282
283
else :
283
284
strCmd = 'SendToUnitySelection'
284
285
self .displayDebug ('doIt {0}' .format (strCmd ))
0 commit comments