Ive been working on this issue for a while and cant seem to get it quite right. I have a batch render script that works for rendering each model individually inside a collection. The problem is when I import 100+ items into blender they don't seem to load in, in order.

Using Blender Python, How can I:

  • Import 1.glb
  • render 1.jpeg
  • Delete/hide 1.glb in blender
  • Import 2.glb etc.

so that each jpeg file rendered lines up with the glb file name in the folder.

Any help would be greatly appreciated!


1 Answer 1


I actually built a script for this a while ago: https://github.com/torrinworx/Blend_My_NFTs/blob/main/src/Model_Generators/Model_Generator.py

It was made for a different purpose, importing/exporting randomized 3D models, but the core functionality of what you are looking for is there. With some slight modifications you can have this up and running:

The approach

The script needs to import the files, turn on the render cameras, render and export an image, select, then delete the files (now scene objects) you imported. All of that is looped through the directory you are storing the .glb files in, for each .glb file.


import bpy
import os

path_to_glb_folder = "/Users/Path/To/Folder" # If you are using Windows use r"\Users\Path\To\Folder"
path_to_jpeg_folder = "/Users/Path/To/Folder"

def deleteAllObjects():
    Deletes all objects in the current scene
    deleteListObjects = ['MESH', 'CURVE', 'SURFACE', 'META', 'FONT', 'HAIR', 'POINTCLOUD', 'VOLUME', 'GPENCIL',
                         'ARMATURE', 'LATTICE', 'EMPTY', 'LIGHT', 'LIGHT_PROBE', 'CAMERA', 'SPEAKER']

    # Select all objects in the scene to be deleted:

    for o in bpy.context.scene.objects:
        for i in deleteListObjects:
            if o.type == i:
    bpy.ops.object.delete() # Deletes all selected objects in the scene


glb_dirList = os.listdir(path_to_glb_folder)

removeList = [".gitignore", ".DS_Store"] # If you have . files in your directory
glb_dirList = [x for x in glb_dirList if (x not in removeList)]

for i in glb_dirList:
    bpy.ops.import_scene.gltf(filepath=os.path.join()) # Import .glb file to scene

    bpy.context.scene.render.filepath = path_to_jpeg_folder # Set save path for images
    bpy.context.scene.render.image_settings.file_format = "JPEG" # Set image file format
    bpy.ops.render.render(write_still=True) # Tell Blender to render an image

  • $\begingroup$ Is there a script to do this for all .gltf files in a folder? $\endgroup$
    – VoxelSoup
    Commented Dec 2, 2022 at 19:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .