# 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, question, UE4-27\
**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:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_674a0c2f1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_674a0c2f1](https://forums.unrealengine.com/u/anonymous_user_674a0c2f1)\
**Post date:** [January 12, 2022, 9:57pm UTC](https://forums.unrealengine.com/t/how-to-batch-export-scene-components-to-glb-gltf-file/272036/1 "2022-01-12T21:57:21Z")

</div>

Hello,  
What I want is to batch export my scene components or blueprint actor as glb/glTF file.

I found a free plugin (glTF Exporter) from Unreal Marketplace which is a great plugin that help me to export my scene component or blueprint actor as glTF/glb file.

But the problem is that if I have dozens of actor in my scene then I have to select one by one to export them and every time I export, the prompt appear on the screen. And this plugin and built-in fbx exporter merge all selected actor to one mesh which I definitely don’t want. I want them as separate file.

Then I found another solution to automate this process by executing python script.  
In this case this python script allow me to batch export only asset from content browser.

Python Script: [Export mesh as GLTF with Python - #2 by anonymous\_user\_a1bda113](https://forums.unrealengine.com/t/export-mesh-as-gltf-with-python/232296/2)

So how do I batch export scene component or blueprint actor (not asset from content browser) as glb/glTF file.

Your help is much appreciated.  
Thank you.

---

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

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_674a0c2f1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_674a0c2f1](https://forums.unrealengine.com/u/anonymous_user_674a0c2f1)\
**Post date:** [January 14, 2022, 1:39pm UTC](https://forums.unrealengine.com/t/how-to-batch-export-scene-components-to-glb-gltf-file/272036/3 "2022-01-14T13:39:02Z")

</div>

Thanks, . It works like a charm
