# How to batch export scene components to glb/glTF file

**URL:** <https://forums.unrealengine.com/t/how-to-batch-export-scene-components-to-glb-gltf-file/272036>\
**Category:** Editor Scripting\
**Tags:** unreal-engine, UE4-27, question\
**Created:** [January 12, 2022, 9:57pm UTC](https://forums.unrealengine.com/t/how-to-batch-export-scene-components-to-glb-gltf-file/272036 "2022-01-12T21:57:21Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![UE\_FlavienP](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ue_flavienp/32/1194546_2.png) [@UE\_FlavienP](https://forums.unrealengine.com/u/UE_FlavienP)\
**Post date:** [January 13, 2022, 1:33pm UTC](https://forums.unrealengine.com/t/how-to-batch-export-scene-components-to-glb-gltf-file/272036/2 "2022-01-13T13:33:19Z")

</div>

You can tweak a bit the script to:

- make it iterate on actors in your scene
- for each actor you will select them
- then export to gltf but only the selected elements

In the following code notice that:

- task.object is using the world
- task.selected is true (if you do not it will export the full level)
- task.options is a unreal.GLTFExportOptions()

You can iterate over actors and select them with something like that

```auto
for actor in unreal.EditorLevelLibrary.get_all_level_actors():
    selected_actors = [actor]
    unreal.EditorLevelLibrary.set_selected_level_actors(selected_actors)

```

and then you can export each selected actor or group of selected actors.

```auto
    task = unreal.AssetExportTask()
    # this could be just one asset if you only want to export one single asset
    task.object = selected_actors[0].get_world()
    task.filename = output_file
    task.selected = True
    task.prompt = False
    task.automated = True
    task.options = unreal.GLTFExportOptions()
    unreal.Exporter.run_asset_export_task(task)

```

---

_[View the full topic](https://forums.unrealengine.com/t/how-to-batch-export-scene-components-to-glb-gltf-file/272036)._
