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
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)
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)
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)