Mercurial > games > semicongine
comparison scripts/blender_gltf_converter.py @ 389:ae8a6c6ff468
add: importer-script for blender
| author | Sam <sam@basx.dev> |
|---|---|
| date | Tue, 05 Dec 2023 22:46:32 +0700 |
| parents | |
| children | 1727bec9ca2f |
comparison
equal
deleted
inserted
replaced
| 388:405bb1fb52b8 | 389:ae8a6c6ff468 |
|---|---|
| 1 import os | |
| 2 import sys | |
| 3 | |
| 4 import bpy | |
| 5 | |
| 6 | |
| 7 def runner(): | |
| 8 argv = sys.argv | |
| 9 print(sys.argv) | |
| 10 script_args = sys.argv[sys.argv.index("--") + 1 :] | |
| 11 inputfile = script_args[0] | |
| 12 outputfile = script_args[1] | |
| 13 if not os.path.exists(inputfile): | |
| 14 print(f"Input file '{inputfile}' does not exists") | |
| 15 quit(1) | |
| 16 if not outputfile.endswith(".glb"): | |
| 17 print(f"Output file '{outputfile}' is not a *.glb file") | |
| 18 | |
| 19 bpy.ops.wm.open_mainfile(filepath=inputfile) | |
| 20 bpy.ops.export_scene.gltf(filepath=outputfile[:-4], export_apply=True) | |
| 21 | |
| 22 | |
| 23 if __name__ == "__main__": | |
| 24 runner() |
