Skip to content
← Back to Blog tutorials

Batch exporting GLB files from Blender with Python

By BitSoul3D4 min read183 views

Batch GLB export from Blender is one of those workflow improvements that pays back its setup cost the moment you hit a scene with 30 props. Manually exporting each asset one at a time — navigating menus, typing filenames, confirming settings — burns hours that belong in the engine. A single Python script automates the whole process: one collection per file, consistent transform application, correct settings, repeatable every build.

Batch exporting GLB files from Blender with Python

Why batch export matters for indie game pipelines

Why batch export matters for indie game pipelines — illustrated

Most indie teams underestimate the compounding cost of manual export. Ten assets today, fifty next sprint, a hundred by alpha. Each manual export introduces variance: a forgotten Apply Transforms step leaves a mesh rotated 90° in Unity; a mistyped filename breaks a Godot import preset; a changed export setting silently strips material names. Scripted batch export eliminates all of that.

The key advantages:

The BitSoul marketplace ships 747 GLB-format assets — the same format this workflow targets. Drop downloaded assets into a Blender scene, modify them, then re-export with your project's exact settings in one run.

Setting up the Blender Python environment for GLB export

Blender's scripting workspace exposes the full bpy API. No external packages needed — GLB export is built into bpy.ops.export_scene.gltf. Open the Scripting workspace, create a new text block, and you're ready.

Before writing the script, decide on your collection-per-asset convention. The approach below treats each top-level collection as one exported GLB file. Nest all objects for a prop (mesh, armature, collision proxy, empties) under a single collection named after the asset:

Scene Collection
├── SM_Crate_Wood      (mesh + UCX_ collision child)
├── SM_Barrel_Metal    (mesh)
└── SM_Table_Oak       (mesh + LOD1 child)

Writing the batch export script

The decisive logic is a single export_collection function. Set OUTPUT_DIR to a path relative to your .blend (e.g. //export/) and flip APPLY_MODIFIERS or EXPORT_TEXTURES as needed. The outer loop iterates bpy.context.scene.collection.children, skips collections whose name starts with EXCLUDE_PREFIX, calls the function below, and logs [OK] or [ERR] per asset.

import bpy, os

OUTPUT_DIR      = "//export/"  # relative to .blend
EXCLUDE_PREFIX  = "_"          # collections starting with _ are skipped
APPLY_MODIFIERS = True
EXPORT_TEXTURES = True

def export_collection(col, out_dir):
    filepath = os.path.join(out_dir, col.name + ".glb")
    bpy.ops.object.select_all(action='DESELECT')
    for obj in col.all_objects:
        if obj.type in {'MESH', 'ARMATURE', 'EMPTY'}:
            obj.select_set(True)
    if APPLY_MODIFIERS:
        bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
    bpy.ops.export_scene.gltf(
        filepath=filepath, use_selection=True, export_format='GLB',
        export_apply=APPLY_MODIFIERS, export_yup=True,
        export_image_format='AUTO' if EXPORT_TEXTURES else 'NONE',
    )
    return filepath

Key export flags:

FlagValueWhy
export_yupTrueGLB spec and Unity/UE5/Godot use Y-up
export_applyTrueBakes modifiers before export
export_format'GLB'Single binary file, not glTF+bin+textures
export_image_format'AUTO'Keeps PNG/JPEG as-is; avoids unnecessary re-encode
export_draco_mesh_compression_enableFalseMost game engines don't support Draco at runtime

Run the script headless — no Blender GUI required — via blender my_assets.blend --background --python batch_export.py 2>&1 | tee export_log.txt. Pipe to a log file for CI pipelines.

Integrating batch export into Unity and Unreal Engine 5 import pipelines

Integrating batch export into Unity and Unreal Engine 5 import pipelines — illustrated

The script drops files into a flat export/ directory. For engine integration, extend the OUTPUT_DIR logic to mirror your project's asset folder structure.

Unity: point OUTPUT_DIR at Assets/Models/Props/. Unity's Auto Refresh picks up new GLBs immediately. Pair with an AssetPostprocessor script to enforce import settings (Read/Write disabled, Generate Lightmap UVs on, mesh compression to High) automatically on every new file.

Unreal Engine 5: UE5 doesn't watch arbitrary folders, so trigger an Interchange import via Python after export. Inside an Editor Utility, create an unreal.AssetImportTask(), set task.automated = True and task.destination_path = '/Game/Props/', then call unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task]) for each .glb in your export directory.

Godot 4: GLB files placed under res:// are auto-imported. Add a .import override file per asset to lock settings (e.g. generate/shadow_meshes=true), then commit both the GLB and its .import to version control so team members don't see reimport prompts.

Checklist before running the script on a full scene

Batch export scripts are one of the highest-ROI automation investments for any 3D game pipeline. Set it up once, run it every build, and stop thinking about export settings forever. Browse the BitSoul marketplace for production-ready GLB assets compatible with this exact workflow.


This post is part of the Ultimate Guide to Free 3D Game Assets — BitSoul's complete reference for formats, texturing, rigging, optimization, and engine integration.


Need drop-in assets for this workflow? Grab the Architecture Modern Bundle on the BitSoul marketplace and drop them straight into your project.

Tags: architecture

Skip the modeling — download it instead

A free BitSoul3D account gets you 2 GLB downloads every month for personal use plus 25 one-time AI Engine credits, no card required. PBR-textured GLB downloads with a full 3D preview before you buy, for Unreal, Unity, Godot or Blender — OBJ and 3D-printable STL come with any purchase or paid plan.

Browse 1,051 models — from $4.99 → or start free (2 downloads a month)