示例#1
0
    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 _save_session(self, path, version, item):
        """
        Save the current session to the supplied path.
        """
        ensure_folder_exists(os.path.dirname(path))
        tde4.saveProject(path)

        # Save the updated property
        item.properties.path = path
示例#3
0
    def save_as(self, version, run_pre_publishers=True):
        """runs when saving a document

        :param version:
        :param run_pre_publishers:
        :return:
        """

        import tde4

        tde4.setProjectPath(version.absolute_full_path)
        tde4.saveProject(version.absolute_full_path)
示例#4
0
    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)
示例#6
0
    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