# HG changeset patch # User Sam # Date 1701791192 -25200 # Node ID 013ed7a37709a2e495b159a1912d104b54e5dea0 # Parent c241b9e9a976ba1da994f2c9a465b4278223a99e add: importer-script for blender diff -r c241b9e9a976 -r 013ed7a37709 scripts/blender_gltf_converter.py --- /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()