Mercurial > games > semicongine
comparison scripts/blender_gltf_converter.py @ 851:8f0c82acb922
did: finish importing system
author | Sam <sam@basx.dev> |
---|---|
date | Wed, 06 Dec 2023 00:05:55 +0700 |
parents | 013ed7a37709 |
children |
comparison
equal
deleted
inserted
replaced
850:013ed7a37709 | 851:8f0c82acb922 |
---|---|
3 | 3 |
4 import bpy | 4 import bpy |
5 | 5 |
6 | 6 |
7 def runner(): | 7 def runner(): |
8 argv = sys.argv | |
9 print(sys.argv) | |
10 script_args = sys.argv[sys.argv.index("--") + 1 :] | 8 script_args = sys.argv[sys.argv.index("--") + 1 :] |
11 inputfile = script_args[0] | 9 for i in range(0, len(script_args), 2): |
12 outputfile = script_args[1] | 10 inputfile = script_args[i] |
13 if not os.path.exists(inputfile): | 11 outputfile = script_args[i + 1] |
14 print(f"Input file '{inputfile}' does not exists") | 12 if not os.path.exists(inputfile): |
15 quit(1) | 13 print(f"Input file '{inputfile}' does not exists") |
16 if not outputfile.endswith(".glb"): | 14 quit(1) |
17 print(f"Output file '{outputfile}' is not a *.glb file") | 15 if not outputfile.endswith(".glb"): |
16 print(f"Output file '{outputfile}' is not a *.glb file") | |
17 quit(1) | |
18 | 18 |
19 bpy.ops.wm.open_mainfile(filepath=inputfile) | 19 bpy.ops.wm.open_mainfile(filepath=inputfile) |
20 bpy.ops.export_scene.gltf(filepath=outputfile[:-4], export_apply=True) | 20 bpy.ops.export_scene.gltf(filepath=outputfile[:-4], export_apply=True) |
21 | 21 |
22 | 22 |
23 if __name__ == "__main__": | 23 if __name__ == "__main__": |
24 runner() | 24 runner() |