コード例 #1
0
def export_level_to_fbx(level_name, output_file):
    """Export an entire level to a static FBX.
    
    Args:
        level_name (str): Name of the level to export.
        output_file (str): file to output to.
    """
    # Get registry of assets
    asset_registry = unreal.AssetRegistryHelpers.get_asset_registry()
    levels = asset_registry.get_assets_by_class("World")
    # Find level matching name
    level_to_export = None
    for level in levels:
        if level.asset_name == level_name:
            level_to_export = level.get_asset()
    if not level_to_export:
        return
    # Create export task
    export_task = unreal.AssetExportTask()
    export_task.object = level_to_export
    export_task.filename = output_file
    export_task.automated = True
    # Populate export options.
    export_options = unreal.FbxExportOption()
    export_options.ascii = True
    export_options.level_of_detail = False
    export_task.options = export_options
    export_task.prompt = False
    export_task.exporter = unreal.LevelExporterFBX()
    # Export
    unreal.ExporterFBX.run_asset_export_task(export_task)
コード例 #2
0
def staticmesh_for_export_task_option():
    options = unreal.FbxExportOption()
    options.ascii = False
    options.collision = False
    options.level_of_detail = False
    options.map_skeletal_motion_to_root = False
    options.vertex_color = False
    options.export_preview_mesh = False
    options.force_front_x_axis = False
    return options
コード例 #3
0
ファイル: ueAssets.py プロジェクト: chinanoodles/ue4_scripts
    def buildStaticMeshExportOptions(self):
        options = unreal.FbxExportOption()
        # unreal.FbxImportUI
        options.set_editor_property('collision', False)

        options.set_editor_property('vertex_color', False)
        options.set_editor_property('map_skeletal_motion_to_root',
                                    False)  # Static Mesh
        options.set_editor_property('level_of_detail', False)
        #options.set_editor_property('fbx_export_compatibility',unreal.FbxExportCompatibility.FBX_2016)
        return options
コード例 #4
0
def unreal_export_fbx(fbx_file):
    import unreal
    # NOTE 通过 C++ 实现 TimmyToolkitBPLibrary
    # NOTE 获取当前 Sequencer 中的 LevelSequence
    sequence = unreal.TimmyToolkitBPLibrary.get_focus_sequence()
    # NOTE 获取当前 Sequencer 中选中的 Bindings
    bindings_list = unreal.TimmyToolkitBPLibrary.get_focus_bindings()

    if bindings_list:
        option = unreal.FbxExportOption()
        option.set_editor_property("collision", False)
        world = unreal.EditorLevelLibrary.get_editor_world()
        unreal.SequencerTools.export_fbx(world, sequence, bindings_list,
                                         option, fbx_file)
コード例 #5
0
def export_fbx(map_asset_path, sequencer_asset_path, output_file):
        # Load the map, get the world
        world = unreal.EditorLoadingAndSavingUtils.load_map(map_asset_path)
	# Load the sequence asset
	sequence = unreal.load_asset(sequencer_asset_path, unreal.LevelSequence)
	# Set Options
	export_options = unreal.FbxExportOption()
	export_options.ascii = True
	export_options.level_of_detail = False
        # Get Bindings
	bindings = sequence.get_bindings()
        # Export
	unreal.SequencerTools.export_fbx(world, sequence, bindings, export_options, output_file)

	return
コード例 #6
0
def export_sequencer_to_fbx(map_asset_path, sequencer_asset_path, output_file):
    """Export animated data from sequencer to fbx file.

    Args:
        map_asset_path (str): Path of the level to load.
        sequencer_asset_path (str): Path of the sequencer to export.
        output_file (str): file to output to.
    """
    # Load the map, get the world
    world = unreal.EditorLoadingAndSavingUtils.load_map(map_asset_path)
    # Load the sequence asset
    sequence = unreal.load_asset(sequencer_asset_path, unreal.LevelSequence)
    # Set Options
    export_options = unreal.FbxExportOption()
    export_options.ascii = True
    export_options.level_of_detail = False
    bindings = sequence.get_bindings()
    # Export
    unreal.SequencerTools.export_fbx(world, sequence, bindings, export_options,
                                     output_file)
コード例 #7
0
def export_fbx(asset_path, destination_folder=None):

    task = ue.AssetExportTask()
    task.object = ue.load_object(None, asset_path)
    print("Exporting object: {0}".format(task.object))
    if task.object is None:
        return

    asset_name, content_path, mirrored_path = mirrored_asset_path(asset_path)

    if not destination_folder:
        destination_folder = os.path.join(get_ue_project_root(), "AssetsFiles",
                                          "ImportFiles", mirrored_path)

    if not os.path.isdir(destination_folder):
        os.mkdir(destination_folder)

    filename = os.path.join(destination_folder, asset_name + ".fbx")

    task.automated = True
    task.filename = filename
    task.selected = False
    task.replace_identical = True
    task.prompt = False
    task.use_file_archive = False
    task.write_empty_files = False

    fbx_export_options = ue.FbxExportOption()
    fbx_export_options.collision = True
    fbx_export_options.fbx_export_compatibility = ue.FbxExportCompatibility.FBX_2013
    fbx_export_options.force_front_x_axis = False
    fbx_export_options.level_of_detail = True
    fbx_export_options.map_skeletal_motion_to_root = False
    fbx_export_options.vertex_color = True
    task.options = fbx_export_options

    export_result = ue.Exporter.run_asset_export_tasks([task])
    print("Export result: {0}".format(export_result))

    return filename
コード例 #8
0
def _generate_fbx_export_task(destination_path, asset_path, asset_name):
    """
    Create and configure an Unreal AssetExportTask

    :param destination_path: The path where the exported FBX will be placed
    :param asset_path: The Unreal asset to export to FBX
    :param asset_name: The FBX filename to export to
    :return the configured AssetExportTask
    """
    loaded_asset = unreal.EditorAssetLibrary.load_asset(asset_path)

    if not loaded_asset:
        unreal.log_error(
            "Failed to create FBX export task for {}: Could not load asset {}".
            format(asset_name, asset_path))
        return None

    filename = os.path.join(destination_path, asset_name + ".fbx")

    # Setup AssetExportTask for non-interactive mode
    task = unreal.AssetExportTask()
    task.object = loaded_asset  # the asset to export
    task.filename = filename  # the filename to export as
    task.automated = True  # don't display the export options dialog
    task.replace_identical = True  # always overwrite the output

    # Setup export options for the export task
    task.options = unreal.FbxExportOption()
    # These are the default options for the FBX export
    # task.options.fbx_export_compatibility = fbx_2013
    # task.options.ascii = False
    # task.options.force_front_x_axis = False
    # task.options.vertex_color = True
    # task.options.level_of_detail = True
    # task.options.collision = True
    # task.options.welded_vertices = True
    # task.options.map_skeletal_motion_to_root = False

    return task
コード例 #9
0
import unreal

# WARNING - UE4 has a bug in FBX export
# the export of hierarchy should be controled by the editor preference 'Keep Attach Hierarchy'
# but in the code the value of this setting is not checked and the actual variable controling this is uninitialized
# which leads to different behaviors on different sessions... you may or may not get your hierarchy in the FBX...

output_file = 'C:\\Temp\\ue4_output.fbx'

selected_actors = unreal.EditorLevelLibrary.get_selected_level_actors()
if len(selected_actors) == 0:
    print("No actor selected, nothing to export")
    quit()

task = unreal.AssetExportTask()
task.object = selected_actors[0].get_world()
task.filename = output_file
task.selected = True
task.replace_identical = False
task.prompt = False
task.automated = True
task.options = unreal.FbxExportOption()
task.options.vertex_color = False
task.options.collision = False
task.options.level_of_detail = False
unreal.Exporter.run_asset_export_task(task)
コード例 #10
0
ファイル: unreal_export.py プロジェクト: unwave/atool
def get_fbx_export_option():
    options = unreal.FbxExportOption()
    options.collision = False
    options.level_of_detail = False
    options.vertex_color = True
    return options