Download

Unreal Python - Export Selected

I’m not sure the option that I’m missing to get the ‘Export Selected’ script that I’m writing to work. In the output log, I get ‘Warning: No exporter found for None’. Nothing happens.



def export_selected_fbx(file_path='C:\	est'):
task = unreal.AssetExportTask()
task.set_editor_property('selected', True)
task.set_editor_property('filename', file_path)
task.set_editor_property('automated', True)

fbx_options = unreal.FbxExportOption()
fbx_options.set_editor_property('collision', False)
fbx_options.set_editor_property('force_front_x_axis', False)
fbx_options.set_editor_property('level_of_detail', False)
task.set_editor_property('options', fbx_options)


result = unreal.Exporter.run_asset_export_task(task)
print 'Export Result: {}'.format(result)

I then thought of setting the exporter and it crashes unreal.


def export_selected_fbx(file_path='C:\	est'):
task = unreal.AssetExportTask()
task.set_editor_property('selected', True)
task.set_editor_property('filename', file_path)
task.set_editor_property('automated', True)
task.set_editor_property('exporter', unreal.ExporterFBX())

fbx_options = unreal.FbxExportOption()
fbx_options.set_editor_property('collision', False)
fbx_options.set_editor_property('force_front_x_axis', False)
fbx_options.set_editor_property('level_of_detail', False)
task.set_editor_property('options', fbx_options)


result = unreal.Exporter.run_asset_export_task(task)
print 'Export Result: {}'.format(result)

Any help would be appreciated.

Well, I figure out the export selected object issue. You need to pass the ‘World’ as your ‘object’. Here is the updated code to help others that may have had the same issue.



# Select your objects in the level
import unreal
def export_selected_fbx(file_path='C:\	est'):
     world = unreal.EditorLevelLibrary.get_editor_world()
     task = unreal.AssetExportTask()
     task.set_editor_property('selected', True)
     task.set_editor_property('filename', file_path)
     task.set_editor_property('automated', True)
     task.set_editor_property('object', world)

     fbx_options = unreal.FbxExportOption()
     fbx_options.set_editor_property('collision', False)
     fbx_options.set_editor_property('force_front_x_axis', False)
     fbx_options.set_editor_property('level_of_detail', False)
     task.set_editor_property('options', fbx_options)

     result = unreal.Exporter.run_asset_export_task(task)
     print 'Export Result: {}'.format(result)