Import multiple object files

Clever script, though unnecessarily complex on how it was written. :slight_smile: It would be now much more easy to understand and modify.

import bpy
import os

def import_models_from_directory(path):
    path = bpy.path.abspath(path)
    extensions = {
        'fbx' : bpy.ops.import_scene.fbx,
        'obj' : bpy.ops.import_scene.obj,
        '3ds' : bpy.ops.import_scene.autodesk_3ds
    }
    filenames = os.listdir(path)
    for f in filenames:
        ex = os.path.splitext(f)[-1].strip('.')
        if ex in extensions:
            extensions[ex](filepath=os.path.join(path, f))
    
directory = r'C:\Users\cos\Documents\Clay Viewer\tmp'
import_models_from_directory(directory)

1 Like