Blender

Blender

Pte Jack Sep 21, 2021 @ 11:12am
Multiple OBJ Imports (Batch Importing??)
I have a model that is comprised of 43 separate OBJ files. I've tried to select all OBJs in the file list to import them. Only the "Active or last selected" OBJ gets imported, not all of them. I really don't want to have to import each OBJ, one at a time.

Is batch importing not supported by the Blender native importer? (I don't see a switch or anything to get Blender to import all 43 OBJs in a single operation.)
Last edited by Pte Jack; Sep 21, 2021 @ 11:13am
< >
Showing 1-7 of 7 comments
Stretchyf Sep 21, 2021 @ 11:35am 
It looks it is solved well with a simple script. Google hinted for Stackexchange, where I got this script.

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:\\', 'objects') # 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)

It imports all objs from a folder, C:\objects here but you can change this. In Linux you can use:
# location of obj folder path_to_obj_dir = '/home/user/Desktop/objects/'
Instead.

I tested it with Blender 2.93 with 2 sample objs in a folder and it worked.
Pte Jack Sep 21, 2021 @ 11:47am 
Thanks Stretchyf, I'll give this a try.

I was thinking about coding something, but my python skills have gotten rusty due to lack of use.
Last edited by Pte Jack; Sep 21, 2021 @ 12:12pm
Pte Jack Sep 21, 2021 @ 12:12pm 
Perfect!!!

Thanks Stretchyf

https://i.imgur.com/ALHqdwS.png

(That was after I joined the 500+ mesh objects created by the import together into 1 object.)

Now to see how many objects I get out of this when I separate by materials.
Last edited by Pte Jack; Sep 21, 2021 @ 12:22pm
Stretchyf Sep 21, 2021 @ 12:22pm 
Glad this worked! Actually binomas linked the same topic on Stackexchange.
Last edited by Stretchyf; Sep 21, 2021 @ 12:22pm
Pte Jack Sep 21, 2021 @ 12:28pm 
Thanks Binomas, I saw the code by Stretchyf first and got too lazy to look at the link.

As for number of objects, 518 only reduced to 435. I need to actually look at materials and textures now to reduce further (DAG!)
Girlgamer87 Sep 21, 2021 @ 1:17pm 
Originally posted by Pte Jack:
Thanks Binomas, I saw the code by Stretchyf first and got too lazy to look at the link.
lul
< >
Showing 1-7 of 7 comments
Per page: 1530 50

Date Posted: Sep 21, 2021 @ 11:12am
Posts: 7