コード例 #1
0
def export_hsl_fbx_from_cur_scene(fbx, force=False):
    """Export HSL format fbx from the current scene.

    This uses the MocapTools library.

    Args:
        fbx (str): path to export to
        force (bool): overwrite existing files without confirmation
    """
    cmds.loadPlugin('fbxmaya', quiet=True)
    install_mocap_tools()
    from MocapTools.Scripts import PsyopMocapTools

    _fbx = File(fbx)
    if _fbx.exists():
        _fbx.delete(wording='Overwrite', force=force)

    _tmp_fbx = File('{}/MocapTools/Anim/Export/{}_SK_Tier1_Male.fbx'.format(
        KEALEYE_TOOLS_ROOT,
        File(host.cur_scene()).basename))
    print ' - TMP FBX', _tmp_fbx.path

    _setup = PsyopMocapTools.mocapSetupTools()
    _tmp_fbx.delete(force=True)
    assert not _tmp_fbx.exists()
    _setup.exportAnim(PsyopMocapTools.config.animFBX)
    assert _tmp_fbx.exists()

    # Move from tmp dir
    _fbx.test_dir()
    shutil.move(_tmp_fbx.path, _fbx.path)
    print ' - SAVED FBX', nice_size(_fbx.path), _fbx.path
コード例 #2
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()
コード例 #3
0
 def test_set_writable(self):
     _test = File('{}/test.txt'.format(_TEST_DIR))
     print "TEST FILE", _test
     if _test.exists():
         _test.set_writable(True)
         _test.delete(force=True)
     _test.touch()
     assert _test.is_writable()
     print _test.set_writable(False)
     assert not _test.is_writable()
     _test.set_writable(True)
     _test.delete(force=True)
コード例 #4
0
def render(file_,
           camera=None,
           layer='defaultRenderLayer',
           col_mgt=True,
           force=False,
           verbose=0):
    """Render the current scene.

    Args:
        file_ (str): path to save rendered image
        camera (str): camera to render through
        layer (str): layer to render
        col_mgt (bool): apply colour management
        force (bool): replace existing without confirmation
        verbose (int): print process data
    """
    from maya_psyhive import open_maya as hom
    cmds.loadPlugin('mtoa', quiet=True)
    from mtoa.cmds import arnoldRender

    _cam = camera
    if not _cam:
        _cam = hom.get_active_cam()

    # Prepare output path
    _file = File(get_path(file_))
    _file.test_dir()
    _file.delete(force=force, wording='Replace')

    # Prepare arnold
    cmds.setAttr("defaultArnoldRenderOptions.abortOnError", False)
    cmds.setAttr("defaultArnoldDriver.colorManagement", int(col_mgt))
    cmds.setAttr("defaultArnoldDriver.mergeAOVs", True)
    _extn = {'jpg': 'jpeg'}.get(_file.extn, _file.extn)
    cmds.setAttr('defaultArnoldDriver.aiTranslator', _extn, type='string')
    cmds.setAttr('defaultArnoldDriver.prefix',
                 "{}/{}".format(_file.dir, _file.basename),
                 type='string')
    cmds.setAttr("defaultRenderGlobals.animation", False)

    # Execute renders
    assert not _file.exists()
    arnoldRender.arnoldRender(640, 640, True, True, _cam, ' -layer ' + layer)
    if not _file.exists():
        _tmp_file = File('{}/{}_1.{}'.format(_file.dir, _file.basename,
                                             _file.extn))
        print ' - TMP FILE', _tmp_file.path
        assert _tmp_file.exists()
        _tmp_file.move_to(_file)
    assert _file.exists()
    lprint('RENDERED IMAGE', _file.path, verbose=verbose)
コード例 #5
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)
コード例 #6
0
    def test_aistandin(self):

        from maya_psyhive.tank_support import ts_aistandin
        set_dev_mode(False)

        _abc = (_DEV_PROJ.path + '/sequences/dev/dev9999/'
                'animation/output/animcache/test_archer/v004/alembic/'
                'dev9999_test_archer_v004.abc')
        _standin = File(_DEV_PROJ.path + '/assets/3D/character/archer/'
                        'shade/output/shadegeo/shade_main/v092/aistandin/'
                        'archer_shade_main_v092.ma')

        # Test build standin output (for Publish Tool)
        _standin.delete(force=True)
        assert not _standin.exists()
        tank_support.build_aistandin_output(output=_standin.path)
        assert _standin.exists()

        # Test apply abc to standin output (for Asset Manager)
        _shade = ref.obtain_ref(_standin.path, namespace='ais_test')
        tank_support.apply_abc_to_shade_aistandin(namespace=_shade.namespace,
                                                  abc=_abc)
        assert _shade.get_node('AISShape').plug('dso').get_val() == _abc

        # Test build standin from shade (for clash holiday)
        _shade_path = (
            _DEV_PROJ.path + '/assets/3D/character/archer/shade/'
            'output/shadegeo/shade_main/v092/maya/archer_shade_main_v092.mb')
        _shade = ref.obtain_ref(namespace='archer_SHD', file_=_shade_path)
        _standin = tank_support.build_aistandin_from_shade(archive=_abc,
                                                           shade=_shade,
                                                           deferred=False)
        assert _standin.shp.plug('dso').get_val() == _abc

        # Test read sg range
        _abc = (_DEV_PROJ.path + '/sequences/dev/dev0000/'
                'animation/output/animcache/aadvark_archer1/v039/alembic/'
                'dev0000_aadvark_archer1_v039.abc')
        assert ts_aistandin._get_abc_range_from_sg(_abc) == (1005, 1015)
コード例 #7
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)
コード例 #8
0
    def test_delete(self):

        _tmp = File('{}/test.file'.format(tempfile.gettempdir()))
        _tmp.touch()
        _tmp.delete(catch=True, force=True)