Ejemplo n.º 1
0
def exctract_current_file_elements(file,
                                   project,
                                   master=True,
                                   from_dresser_tree=True):
    name = files.file_name_no_extension(files.file_name(file))
    elements = name.split("_")

    if cfg.enable_undercore_for_asset_names:
        relative_path = files.relpath_wrapper(file, project.path)
        depth_folders = files.splitall(
            relative_path
        )  # exctract_current_path_levels( file, self.project.path)
        '''THIS WILL GIVE ME THE LENGHT OF THE PARTS SEPERATED WITH AN UNDERSCORE BEFORE THE ASSET NAME:
        depth_folder[2:-2] will crop 'assets_lib' and 'assets' from the start, and file name and stage from the end
        Then, i will add 1 for the project prefix'''
        if from_dresser_tree:
            dynamic_length = len(depth_folders[2:-2]) + 1
        else:
            '''HERE WE NEED TO CONSIDE FOR THE PATH NAME THAT INCLUDES THE ASSET NAME, PLUS STAGE, AND NOT THE assets_lib and assets that will not exist when
            coming from the nodes that were generated by the dresser'''
            dynamic_length = len(depth_folders[:-3])

        dynamic_part = name.split("_")[:dynamic_length]
        static_part = "_".join(name.split("_")[dynamic_length:])
        dynamic_part.append(static_part)
        elements = dynamic_part

    return elements
Ejemplo n.º 2
0
 def thumbnail_file(self):
     filename = files.file_name(self._path)
     filename = files.file_name_no_extension(filename)
     path = os.path.join(
         self._component.tumbnails_path, "%s.%s" %
         (filename, "png")) if self._component.tumbnails_path else ""
     # if os.path.isfile(path):
     return path
Ejemplo n.º 3
0
 def rename(self, new_name):
     version_number_padded = self.component.padding(self.name)
     file_name = "{0}_{1}{2}".format(self.component.format_file_name,
                                     cfg._public_version_pfx_,
                                     version_number_padded)
     updated_path = os.path.join(self.component.masters_path,
                                 files.file_name(self.path))
     files.file_rename(updated_path, file_name)
Ejemplo n.º 4
0
    def rename(self, new_name):

        version_number_padded = self.component.padding(self.name)
        file_name = "{0}_{1}{2}".format(self.component.format_file_name_full,
                                        cfg._playblast_pfx_,
                                        version_number_padded)
        updated_path = os.path.join(self.component.playblasts_path,
                                    files.file_name(self.path))
        logger.info("upd: {} // new name: {}".format(updated_path, file_name))
        files.file_rename(updated_path, file_name)
Ejemplo n.º 5
0
    def list_saved_presets(self):
        presets_list = list()
        presets = files.list_directory(
            os.path.join(cfg.script_dir(), 'presets'), 'json')
        if presets:
            for p in presets:
                presets_list.append(
                    [p, files.file_name_no_extension(files.file_name(p))])

            return presets_list
        else:
            return list()
Ejemplo n.º 6
0
    def _load_project(pipelineUI=None):

        # path = QtWidgets.QFileDialog.getOpenFileName(pipelineUI, "Select Pipeline project file", filter="*.*")
        path = inputs.FileDialog.get_file(
            caption='Select Pipeline project file', filter='*.*')
        if path:

            logger.info(files.file_name(path))
            logger.info(files.extension(files.file_name(path)))
            if files.extension(files.file_name(path)) == ".pipe":
                msg = "This project was created with an older version of Pipeline.\n\n" \
                      "Pipeline data files needs to be converted.\n" \
                      "Original files won't be changed."
                prompt = massage.PromptUser(pipelineUI,
                                            prompt=msg,
                                            override_yes_text="Proceed",
                                            override_no_label="Cancel")
                result = prompt.exec_()
                if result == 0:
                    legacy_projects.Legacy_project(pipelineUI=pipelineUI,
                                                   path=str(path)).convert()
                else:
                    logger.info("Abort project convertion")
                    return

            project_name = files.path.lastdir(os.path.dirname(path))
            project_path = os.path.dirname(path)
            project = projects.ProjectNode(project_name,
                                           parent=None,
                                           pipelineUI=pipelineUI,
                                           path=project_path)

            if project.set():
                pipelineUI.new_project(project)

            pipelineUI.populate_projects_button()

            return True

        return False
Ejemplo n.º 7
0
def import_obj(path=None, namespace = True):
    if os.path.exists(path):
        try:
            cmds.loadPlugin("objExport", qt=True)
            namesspace = files.file_name_no_extension(files.file_name(path))
            import_file = os.path.normpath(cmds.file(path, ns=namesspace, type="OBJ", i=True, esn=True, options = "mo=1;lo=0", ra=True, mergeNamespacesOnClash = False))

            if not namesspace:
                remove_all_namespaces()

            return import_file

        except:
            logger.info("could not import obj file: {}".format(path))
Ejemplo n.º 8
0
    def add_script(self, *args):
        path = QtWidgets.QFileDialog.getOpenFileName(None,
                                                     "Select script file",
                                                     filter="*.*")
        if path[0]:

            typ = files.extension(files.file_name(path[0]))
            if typ == ".py" or typ == ".mel":
                item = dt.ScriptFileNode(name='script', path=path[0])
            else:
                return
        else:
            return

        scripts_model = self.scripts_table_view.model()
        scripts_model.insertRows(0, 1, QtCore.QModelIndex(), node=item)

        return
Ejemplo n.º 9
0
def import_scene(path=None):
    if os.path.exists(path):
        namesspace = files.file_name_no_extension(files.file_name(path))
        return os.path.normpath(cmds.file(path, i=True, f=True, ns=namesspace, esn=False, preserveReferences=True))
Ejemplo n.º 10
0
def reference_scene(path=None):
    if os.path.exists(path):
        namesspace = files.file_name_no_extension(files.file_name(path))
        return os.path.normpath(cmds.file(path, r=True, f=True, ns=namesspace, esn=False))