mirror of
https://forge.apps.education.fr/blender-edutech/blender-edutech.git
synced 2024-01-27 08:20:37 +01:00
24 lines
924 B
Python
24 lines
924 B
Python
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('/home/phroy/Bureau/a')
|
|
# get list of all files in directory
|
|
file_list = sorted(os.listdir(path_to_obj_dir))
|
|
print (file_list)
|
|
|
|
|
|
# get a list of files ending in 'dae'
|
|
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:
|
|
print(item)
|
|
path_to_file = os.path.join(path_to_obj_dir, item)
|
|
#bpy.ops.wm.obj_import(path_to_file, path_to_obj_dir, item)
|
|
bpy.ops.import_scene.obj(filepath=path_to_file)
|
|
#bpy.ops.wm.obj_import(filepath = path_to_file)
|
|
# if heavy importing is expected
|
|
# you may want use saving to main file after every import
|
|
bpy.ops.wm.save_mainfile(filepath = "/home/phroy/Bureau/a/file.blend")
|
|
|