Example #1
0
    def export_selected(self):
        sel = cmds.ls(sl=True)
        if not sel:
            return
        indices = self.file_tree_view.selectedIndexes()
        if indices:
            path = self.file_model.fileInfo(indices[0]).absoluteFilePath()
            directory = os.path.dirname(path) if os.path.isfile(path) else path
        else:
            directory = self.file_model.rootPath()

        for mesh in sel:
            path = os.path.join(directory, "{}.obj".format(mesh))
            export_obj(mesh, path)
Example #2
0
def export_blendshape_targets(blendshape, directory):
    """Export all targets of a blendshape as objs.

    :param blendshape: Blendshape name
    :param directory: Directory path
    """
    connections = zero_weights(blendshape)
    targets = get_target_list(blendshape)
    base = cmds.blendShape(blendshape, q=True, g=True)[0]
    for t in targets:
        plug = "{}.{}".format(blendshape, t)
        cmds.setAttr(plug, 1)
        file_path = os.path.join(directory, "{}.obj".format(t))
        export_obj(base, file_path)
        cmds.setAttr(plug, 0)
    restore_weights(blendshape, connections)