Exemple #1
0
def _save_fbx(file_, force=False):
    """Save fbx file.

    Args:
        file_ (str): fbx path
        force (bool): replace without confirmation
    """
    _file = File(get_path(file_))
    _file.delete(wording='Replace', force=force)
    for _mel in [
            'FBXExportUpAxis z',
            'FBXExportFileVersion -v FBX201800',
            'FBXExportSmoothingGroups -v true',
            'FBXExportSmoothMesh -v true',
            'FBXExportTangents -v true',
            'FBXExportSkins -v true',
            'FBXExportShapes -v true',
            'FBXExportEmbeddedTextures -v false',
            'FBXExportApplyConstantKeyReducer -v true',
            'FBXExportSplitAnimationIntoTakes -c',
            'FBXExport -f "{}"'.format(_file.path),
    ]:
        mel.eval(_mel)
    dprint('Wrote file', _file.nice_size(), _file.path)
    assert _file.exists()
Exemple #2
0
def save_as(file_, revert_filename=True, force=False, verbose=0):
    """Save the current scene at the given path without changing cur filename.

    Args:
        file_ (str): path to save file to
        revert_filename (bool): disable revert filename
        force (bool): overwrite with no confirmation
        verbose (int): print process data
    """
    _cur_filename = hou.hipFile.name()

    # Test file paths
    _file = File(abs_path(get_path(file_)))
    _file.delete(wording='replace existing', force=force)

    # Execute save
    _file.test_dir()
    hou.hipFile.save(_file.path)
    dprint('SAVED SCENE', _file.nice_size(), _file.path, verbose=verbose)

    if revert_filename:
        hou.hipFile.setName(_cur_filename)
Exemple #3
0
def save_as(file_,
            revert_filename=True,
            export_selection=False,
            force=False,
            verbose=0):
    """Save the current scene at the given path without changing cur filename.

    Args:
        file_ (str): path to save file to
        revert_filename (bool): disable revert filename
        export_selection (bool): export selected nodes
        force (bool): overwrite with no confirmation
        verbose (int): print process data
    """
    _cur_filename = cmds.file(query=True, location=True)

    # Test file paths
    _file = File(abs_path(file_))
    _file.delete(wording='replace existing', force=force)

    # Execute save
    _file.test_dir()
    cmds.file(rename=_file.path)
    _kwargs = {
        'save' if not export_selection else 'exportSelected': True,
        'type': {
            'ma': 'mayaAscii',
            'mb': 'mayaBinary'
        }[_file.extn]
    }
    cmds.file(options="v=0;", **_kwargs)
    dprint('SAVED SCENE', _file.nice_size(), _file.path, verbose=verbose)
    lprint(' - KWARGS', _kwargs, verbose=verbose > 1)

    if revert_filename:
        cmds.file(rename=_cur_filename)