Example #1
0
    def export_as(self, version):
        """the export action for maya environment
        """
        # check if there is something selected
        if len(pm.ls(sl=True)) < 1:
            raise RuntimeError("There is nothing selected to export")

        # do not save if there are local files
        self.check_external_files()

        # set the extension to ma by default
        version.extension = '.ma'

        # create the folder if it doesn't exists
        utils.createFolder(version.path)

        workspace_path = os.path.dirname(version.path)

        self.create_workspace_file(workspace_path)
        self.create_workspace_folders(workspace_path)

        # export the file
        pm.exportSelected(version.full_path, type='mayaAscii')

        # save the version
        version.save()

        return True
Example #2
0
    def export_as(self, version):
        """the export action for maya environment
        """
        # check if there is something selected
        if len(pm.ls(sl=True)) < 1:
            raise RuntimeError("There is nothing selected to export")

        # do not save if there are local files
        self.check_external_files()

        # set the extension to ma by default
        version.extension = '.ma'

        # create the folder if it doesn't exists
        utils.createFolder(version.path)

        workspace_path = os.path.dirname(version.path)

        self.create_workspace_file(workspace_path)
        self.create_workspace_folders(workspace_path)

        # export the file
        pm.exportSelected(version.full_path, type='mayaAscii')

        # save the version
        version.save()

        return True
Example #3
0
    def create(self):
        """Creates the project directory structure and saves the project, thus
        creates the ``.metadata.db`` file in the repository.
        """

        # check if the folder already exists
        utils.mkdir(self.full_path)

        # create the structure if it is not present
        rendered_structure = jinja2.Template(self.structure).\
                             render(project=self)

        folders = rendered_structure.split("\n")

        if len(folders):
            for folder in rendered_structure.split("\n"):
                try:
                    utils.createFolder(folder.strip())
                except OSError:
                    pass

        self._exists = True

        self.save()
Example #4
0
    def create(self):
        """Creates the project directory structure and saves the project, thus
        creates the ``.metadata.db`` file in the repository.
        """
        
        # check if the folder already exists
        utils.mkdir(self.full_path)

        # create the structure if it is not present
        rendered_structure = jinja2.Template(self.structure).\
                             render(project=self)
        
        folders = rendered_structure.split("\n")
        
        if len(folders):
            for folder in rendered_structure.split("\n"):
                try:
                    utils.createFolder(folder.strip())
                except OSError:
                    pass
        
        self._exists = True
        
        self.save()
Example #5
0
    def save_as(self, version):
        """The save_as action for maya environment.

        It saves the given Version instance to the Version.full_path.
        """
        # do not save if there are local files
        self.check_external_files()

        # set version extension to ma
        version.extension = '.ma'

        project = version.project

        current_workspace_path = pm.workspace.path

        # create a workspace file inside a folder called .maya_files
        # at the parent folder of the current version
        workspace_path = os.path.dirname(version.path)

        # if the new workspace path is not matching the with the previous one
        # update the external paths to absolute version
        logger.debug("current workspace: %s" % current_workspace_path)
        logger.debug("next workspace: %s" % workspace_path)

        if current_workspace_path != workspace_path:
            logger.debug("changing workspace detected!")
            logger.debug("converting paths to absolute, to be able to "
                         "preserve external paths")

            # replace external paths with absolute ones
            self.replace_external_paths(mode=1)

        # create the workspace folders
        self.create_workspace_file(workspace_path)

        # this sets the project
        pm.workspace.open(workspace_path)

        # create workspace folders
        self.create_workspace_folders(workspace_path)

        # only if the file is a new version
        if version.version_number == 1:
            # set scene fps
            self.set_fps(project.fps)

            # set render resolution
            self.set_resolution(project.width, project.height,
                                project.pixel_aspect)
            # set the render range
            if version.type.type_for == 'Shot':
                self.set_frame_range(version.version_of.start_frame,
                                     version.version_of.end_frame)

        # set the render file name and version
        self.set_render_fileName(version)

        # set the playblast file name
        self.set_playblast_file_name(version)

        # create the folder if it doesn't exists
        utils.createFolder(version.path)

        # delete the unknown nodes
        unknownNodes = pm.ls(type='unknown')
        pm.delete(unknownNodes)

        # set the file paths for external resources
        self.replace_external_paths(mode=1)

        # save the file
        pm.saveAs(version.full_path, type='mayaAscii')

        # update the reference list
        self.update_references_list(version)

        # append it to the recent file list
        self.append_to_recent_files(version.full_path)

        return True
Example #6
0
    def save_as(self, version):
        """The save_as action for maya environment.

        It saves the given Version instance to the Version.full_path.
        """
        # do not save if there are local files
        self.check_external_files()

        # set version extension to ma
        version.extension = '.ma'

        project = version.project

        current_workspace_path = pm.workspace.path

        # create a workspace file inside a folder called .maya_files
        # at the parent folder of the current version
        workspace_path = os.path.dirname(version.path)

        # if the new workspace path is not matching the with the previous one
        # update the external paths to absolute version
        logger.debug("current workspace: %s" % current_workspace_path)
        logger.debug("next workspace: %s" % workspace_path)

        if current_workspace_path != workspace_path:
            logger.debug("changing workspace detected!")
            logger.debug("converting paths to absolute, to be able to "
                         "preserve external paths")

            # replace external paths with absolute ones
            self.replace_external_paths(mode=1)

        # create the workspace folders
        self.create_workspace_file(workspace_path)

        # this sets the project
        pm.workspace.open(workspace_path)

        # create workspace folders
        self.create_workspace_folders(workspace_path)

        # only if the file is a new version
        if version.version_number == 1:
            # set scene fps
            self.set_fps(project.fps)

            # set render resolution
            self.set_resolution(project.width, project.height,
                                project.pixel_aspect)
            # set the render range
            if version.type.type_for == 'Shot':
                self.set_frame_range(
                    version.version_of.start_frame,
                    version.version_of.end_frame
                )

        # set the render file name and version
        self.set_render_fileName(version)

        # set the playblast file name
        self.set_playblast_file_name(version)

        # create the folder if it doesn't exists
        utils.createFolder(version.path)

        # delete the unknown nodes
        unknownNodes = pm.ls(type='unknown')
        pm.delete(unknownNodes)

        # set the file paths for external resources
        self.replace_external_paths(mode=1)

        # save the file
        pm.saveAs(
            version.full_path,
            type='mayaAscii'
        )

        # update the reference list
        self.update_references_list(version)

        # append it to the recent file list
        self.append_to_recent_files(
            version.full_path
        )

        return True