|
import sys
|
|
import bpy
|
|
import os
|
|
import os.path
|
|
argv = sys.argv[sys.argv.index("--") + 1:]
|
|
if len(argv) == 0:
|
|
print("No input .obj file given")
|
|
exit(1)
|
|
if len(argv) == 1:
|
|
print("No output directory given")
|
|
exit(2)
|
|
|
|
for c in bpy.context.scene.collection.children:
|
|
bpy.context.scene.collection.children.unlink(c)
|
|
|
|
infile = argv[0]
|
|
output = argv[1]
|
|
base, _ = os.path.splitext(os.path.basename(infile))
|
|
os.makedirs(output, exist_ok=True)
|
|
|
|
bpy.ops.wm.obj_import(filepath=infile)
|
|
|
|
bpy.ops.export_scene.gltf(filepath=os.path.join(output, base),
|
|
export_cameras=True,
|
|
export_lights=True,
|
|
export_format='GLTF_SEPARATE')
|