Import multiple OBJ files at once - using latest Blender

Dear All,
I have checked the internet about this topic and I have found a script - but those articles were dated back to 2012 or 2013. I was able to shift select multiple obj files from my folder but at the end it only imported the last of the checked ones. Is there a way to import multiple obj files into the latest Blender?

EDIT: if there is a way I can do it using .fbx files, no issue. So the question goes both for obj or fbx files.

Thanks for the update.
I have already imported them one by one, but for later use I will keep that im mind.

The above code I have added obj.location so that it import one obj file to each layer, remove this if you want the import to one and only layer.

All right. I will keep that in mind.

Hi I also found this:

//Wilnix

Yes, that I found too. As that is an older thread I was curious if there is a way for this in the newer Blender. But I will get myself accomodated with using the method you linked.

If you want to append multiple .obj or .fbx files you will need to loop over all of the ones in a folder or with predefined paths etc. Since you do not seem to be sold on the idea of a certain file type I will throw in that I much prefer to use .blends because you can setup objects however complicated you would like with materials, mods, particle systems :wink:

Here is a simple function I’ve got to import all objects (from a .blend) into your scene from a given .blend path.

<b>def append_objs_from_blend(path):
    """Appends all objects into scene from .blend found at path."""

    scene = bpy.context.scene

    with bpy.data.libraries.load(path) as (data_from, data_to):
        data_to.objects = [name for name in data_from.objects]

    for obj in data_to.objects:
        if obj is not None:
            scene.objects.link(obj)</b>

Just to show the power of this setup…only imports if the obj’s name starts with prefix, ends with suffix, etc.

<b>def append_objs(path, prefix="", suffix="", case_sens=False, ignore="IGNORE"):
    """Appends all objects into scene from .blend if they meet argument criteria."""

    scene = bpy.context.scene

    with bpy.data.libraries.load(path) as (data_from, data_to):
        if not case_sens:
            data_to.objects = [name for name in data_from.objects if
                               name.lower().startswith(prefix.lower()) and name.lower().endswith(suffix.lower()) and ignore.upper() not in name.upper()]
        else:
            data_to.objects = [name for name in data_from.objects if name.startswith(prefix) and name.endswith(suffix) and ignore.upper() not in name.upper()]

    for obj in data_to.objects:
        if obj is not None:
            scene.objects.link(obj)</b>

Thanks for your help. I shall save this page for later use.

I am trying to use this script in 2.79

import os
import bpy

# put the location to the folder where the objs are located here in this fashion
# this line will only work on windows ie C:\objects
path_to_obj_dir = os.path.join('C:\\', 'Users\Heather\Desktop\Luffy Film Z')

# get list of all files in directory
file_list = sorted(os.listdir(path_to_obj_dir))

# get a list of files ending in 'obj'
obj_list = [item for item in file_list if item.endswith('.obj')]

# loop through the strings in obj_list and add the files to the scene
for item in obj_list:
    path_to_file = os.path.join(path_to_obj_dir, item)
    bpy.ops.import_scene.obj(filepath = path_to_file)

I am getting an error in this line:

file_list = sorted(os.listdir(path_to_obj_dir))

I need something that imports multiple .obj in 2.79.

The script above, I found out, works, but only in C dir. Not sure why.

Fbx bubdle has a batch impirt mode, just specify folder in ui and press import
http://renderhjs.net/fbxbundle/

2 Likes

Just to add. Fbx bundle supports batch import of fbx, obj & 3ds not only fbx as the name implies.

1 Like