def setUp(self): tde4.loadProject( 'c:/_store/dev/3DEtools-env/3DEtools/tests/3de/footage02_v001.3de') # tde4.loadProject('/home/DForgacs/dev/3DEtools/tests/3de/footage02_v001.3de') try: self.tde_file = tde4.getProjectPath() except: print '--> No 3De project is opne...' raise Exception self.tde_path = os.path.dirname(self.tde_file) self.tde_filename = os.path.basename(self.tde_file) self.project = self.tde_filename.split('.')[0] self.mel_filename = self.tde_filename.replace('3de', 'mel') self.mel_file = os.path.join(self.tde_path, 'exports', self.mel_filename) self.camera_id = tde4.getCurrentCamera() self.footage = tde4.getCameraPath(self.camera_id) self.footage_name = os.path.basename(self.footage).split('.')[0] self.exportfolder = os.path.join(self.tde_path, 'exports') if os.path.exists(self.exportfolder): shutil.rmtree(self.exportfolder) assert os.path.exists(self.exportfolder) == False, '--> Export exists' MayaMelExport.main() with open(self.mel_file, 'r') as f: self.melscript = f.read()
def execute(self, operation, file_path, **kwargs): """ Main hook entry point :operation: String Scene operation to perform :file_path: String File path to use if the operation requires it (e.g. open) :returns: Depends on operation: 'current_path' - Return the current scene file path as a String all others - None """ if operation == "current_path": # return the current scene path return tde4.getProjectPath() elif operation == "open": # do new scene as Maya doesn't like opening # the scene it currently has open! tde4.loadProject(file_path) elif operation == "save": current_file = tde4.getProjectPath() tde4.saveProject(current_file)
def test__mm_group_name_in_may_is_mm_plus_filename(self): # 'group -em -name "mm_footage02_v001"' group_name = 'mm_' + self.project self.assertTrue(group_name in self.melscript) # tde4.loadProject('c:/_store/dev/3DEtools-env/3DEtools/tests/3de/footage02_v001.3de') tde4.loadProject( '/home/DForgacs/dev/3DEtools/tests/3de/footage02_v001.3de') mel_file = MayaMelExport.main() with open(mel_file, 'r') as f: melscript = f.read() self.assertTrue('mm_footage02_v001' in melscript) tde4.loadProject( 'c:/_store/dev/3DEtools-env/3DEtools/tests/3de/test_name.3de') # tde4.loadProject('/home/DForgacs/dev/3DEtools/tests/3de/test_name.3de') mel_file = MayaMelExport.main() with open(mel_file, 'r') as f: melscript = f.read() self.assertTrue('mm_test_name' in melscript)
def execute(self, operation, file_path, **kwargs): """ Main hook entry point :operation: String Scene operation to perform :file_path: String File path to use if the operation requires it (e.g. open) :returns: Depends on operation: 'current_path' - Return the current scene file path as a String all others - None """ if operation == "current_path": return tde4.getProjectPath() elif operation == "open": tde4.loadProject(file_path) elif operation == "save": project_path = tde4.getProjectPath() tde4.saveProject(project_path)
def execute(self, operation, file_path, context, parent_action, file_version, read_only, **kwargs): """ Main hook entry point :param operation: String Scene operation to perform :param file_path: String File path to use if the operation requires it (e.g. open) :param context: Context The context the file operation is being performed in. :param parent_action: This is the action that this scene operation is being executed for. This can be one of: - open_file - new_file - save_file_as - version_up :param file_version: The version/revision of the file to be opened. If this is 'None' then the latest version should be opened. :param read_only: Specifies if the file should be opened read-only or not :returns: Depends on operation: 'current_path' - Return the current scene file path as a String 'reset' - True if scene was reset to an empty state, otherwise False all others - None """ if operation == "current_path": # return the current project path return tde4.getProjectPath() elif operation == "open": self._set_preferences(context) tde4.loadProject(file_path) elif operation == "save": project_path = tde4.getProjectPath() tde4.saveProject(project_path) elif operation == "save_as": tde4.saveProject(file_path) elif operation == "reset": """ Reset the scene to an empty state """ while not tde4.isProjectUpToDate(): self.logger.debug(file_path) # changes have been made to the scene res = QtGui.QMessageBox.question( QtGui.QApplication.activeWindow(), "Save your scene?", "Your scene has unsaved changes. Save before proceeding?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel) if res == QtGui.QMessageBox.Cancel: return False elif res == QtGui.QMessageBox.No: break else: project_path = tde4.getProjectPath() if not project_path: # there is no 3de python API to open a save file GUI, so just use sgtk self.parent.engine.commands["File Save..."][ "callback"]() return False else: tde4.saveProject(project_path) # do new file: tde4.newProject() if parent_action == "new_file": self._set_preferences(context) self.parent.engine.commands["File Save..."]["callback"]() # call the task status updates return super(SceneOperation, self).execute(operation, file_path, context, parent_action, file_version, read_only, **kwargs)
def execute(self, operation, file_path, context, parent_action, file_version, read_only, **kwargs): """ Main hook entry point :param operation: String Scene operation to perform :param file_path: String File path to use if the operation requires it (e.g. open) :param context: Context The context the file operation is being performed in. :param parent_action: This is the action that this scene operation is being executed for. This can be one of: - open_file - new_file - save_file_as - version_up :param file_version: The version/revision of the file to be opened. If this is 'None' then the latest version should be opened. :param read_only: Specifies if the file should be opened read-only or not :returns: Depends on operation: 'current_path' - Return the current scene file path as a String 'reset' - True if scene was reset to an empty state, otherwise False all others - None """ if operation == "current_path": # return the current scene path return file_path elif operation == "open": tde4.loadProject(file_path) elif operation == "save": if not os.path.exists(os.path.dirname(file_path)): os.makedirs(os.path.dirname(file_path)) tde4.saveProject(file_path) elif operation == "save_as": if not os.path.exists(os.path.dirname(file_path)): os.makedirs(os.path.dirname(file_path)) tde4.saveProject(file_path) elif operation == "reset": if not tde4.isProjectUpToDate(): res = QtGui.QMessageBox.question( None, "Save your scene?", "Your scene has unsaved changes. Save before proceeding?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel) if res == QtGui.QMessageBox.Cancel: return False else: if not os.path.exists(os.path.dirname(file_path)): os.makedirs(os.path.dirname(file_path)) tde4.saveProject(file_path) return True