diff tools/blender_gltf_converter.py @ 1039:ea9270ed03ea

and even more cleanup of the repo
author sam <sam@basx.dev>
date Sat, 23 Mar 2024 22:57:11 +0700
parents scripts/blender_gltf_converter.py@1727bec9ca2f
children 34ae5835bfa8
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/blender_gltf_converter.py	Sat Mar 23 22:57:11 2024 +0700
@@ -0,0 +1,24 @@
+import os
+import sys
+
+import bpy
+
+
+def runner():
+    script_args = sys.argv[sys.argv.index("--") + 1 :]
+    for i in range(0, len(script_args), 2):
+        inputfile = script_args[i]
+        outputfile = script_args[i + 1]
+        if not os.path.exists(inputfile):
+            print(f"Input file '{inputfile}' does not exists")
+            quit(1)
+        if not outputfile.endswith(".glb"):
+            print(f"Output file '{outputfile}' is not a *.glb file")
+            quit(1)
+
+        bpy.ops.wm.open_mainfile(filepath=inputfile)
+        bpy.ops.export_scene.gltf(filepath=outputfile[:-4], export_apply=True)
+
+
+if __name__ == "__main__":
+    runner()