I want to merge several obj format 3d models and output as a gltf format model.
The directory structure looks like this.
folder_1/1.obj, 1.mlt, 1.jpg
folder_2/2.obj, 2.mlt, 2_1.jpg, 2_2.jpg
folder_3/3obj, 3.mlt, 3_1.jpg, 3_2.jpg, 3_3.jpg
folder_4/4.obj, 4.mlt, 4.jpg
And when I run this code:
folder_paths = ["folder_1", "folder_2", "folder_3", "folder_4"]
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(True)
for folder_path in folder_paths:
obj_file = glob.glob(os.path.join(folder_path, "*.obj"))
bpy.ops.import_scene.obj(filepath=obj_file[0])
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.join()
bpy.ops.export_scene.gltf("merged.gltf", export_format='GLTF_EMBEDDED', ui_tab='GENERAL')
I got this error:
RuntimeError: Operator bpy.ops.object.join.poll() failed, context is incorrect
What should I do?
I appreciate and thank you for your answer.