Example #1
0
def import_obj_directory(directory, base_mesh=None):
    if base_mesh:
        blendshape = get_or_create_blendshape_node(base_mesh)
    for f in os.listdir(directory):
        if not f.lower().endswith(".obj") or f.startswith("_"):
            continue
        full_path = os.path.join(directory, f)
        target = import_obj(full_path)
        if base_mesh:
            add_target(blendshape, target)
            cmds.delete(target)
Example #2
0
    def import_selected_objs(self, add_as_targets=True):
        """Import the selected shapes in the tree view.

        If a mesh with a blendshape is selected in the scene, the shapes will be added
        as targets
        """
        indices = self.file_tree_view.selectedIndexes()
        if not indices:
            return None
        paths = self.get_selected_paths()

        sel = cmds.ls(sl=True)
        blendshape = bs.get_blendshape_node(sel[0]) if sel else None
        meshes = [import_obj(path) for path in paths]
        if blendshape and add_as_targets:
            for mesh in meshes:
                bs.add_target(blendshape, mesh)
                cmds.delete(mesh)
        elif meshes:
            cmds.select(meshes)
        return meshes