annotate scripts/blender_gltf_converter.py @ 422:a03b6db25282

add: text-wrapping, fix: incorrect descriptor poolsizes
author Sam <sam@basx.dev>
date Wed, 31 Jan 2024 00:29:40 +0700
parents 1727bec9ca2f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
389
ae8a6c6ff468 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
1 import os
ae8a6c6ff468 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
2 import sys
ae8a6c6ff468 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
3
ae8a6c6ff468 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
4 import bpy
ae8a6c6ff468 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
5
ae8a6c6ff468 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
6
ae8a6c6ff468 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
7 def runner():
ae8a6c6ff468 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
8 script_args = sys.argv[sys.argv.index("--") + 1 :]
390
1727bec9ca2f did: finish importing system
Sam <sam@basx.dev>
parents: 389
diff changeset
9 for i in range(0, len(script_args), 2):
1727bec9ca2f did: finish importing system
Sam <sam@basx.dev>
parents: 389
diff changeset
10 inputfile = script_args[i]
1727bec9ca2f did: finish importing system
Sam <sam@basx.dev>
parents: 389
diff changeset
11 outputfile = script_args[i + 1]
1727bec9ca2f did: finish importing system
Sam <sam@basx.dev>
parents: 389
diff changeset
12 if not os.path.exists(inputfile):
1727bec9ca2f did: finish importing system
Sam <sam@basx.dev>
parents: 389
diff changeset
13 print(f"Input file '{inputfile}' does not exists")
1727bec9ca2f did: finish importing system
Sam <sam@basx.dev>
parents: 389
diff changeset
14 quit(1)
1727bec9ca2f did: finish importing system
Sam <sam@basx.dev>
parents: 389
diff changeset
15 if not outputfile.endswith(".glb"):
1727bec9ca2f did: finish importing system
Sam <sam@basx.dev>
parents: 389
diff changeset
16 print(f"Output file '{outputfile}' is not a *.glb file")
1727bec9ca2f did: finish importing system
Sam <sam@basx.dev>
parents: 389
diff changeset
17 quit(1)
389
ae8a6c6ff468 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
18
390
1727bec9ca2f did: finish importing system
Sam <sam@basx.dev>
parents: 389
diff changeset
19 bpy.ops.wm.open_mainfile(filepath=inputfile)
1727bec9ca2f did: finish importing system
Sam <sam@basx.dev>
parents: 389
diff changeset
20 bpy.ops.export_scene.gltf(filepath=outputfile[:-4], export_apply=True)
389
ae8a6c6ff468 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
21
ae8a6c6ff468 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
22
ae8a6c6ff468 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
23 if __name__ == "__main__":
ae8a6c6ff468 add: importer-script for blender
Sam <sam@basx.dev>
parents:
diff changeset
24 runner()