diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/blender_gltf_converter.py	Tue Dec 05 22:46:32 2023 +0700
@@ -0,0 +1,24 @@
+import os
+import sys
+
+import bpy
+
+
+def runner():
+    argv = sys.argv
+    print(sys.argv)
+    script_args = sys.argv[sys.argv.index("--") + 1 :]
+    inputfile = script_args[0]
+    outputfile = script_args[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")
+
+    bpy.ops.wm.open_mainfile(filepath=inputfile)
+    bpy.ops.export_scene.gltf(filepath=outputfile[:-4], export_apply=True)
+
+
+if __name__ == "__main__":
+    runner()