Export a Blender file to GLB from the command line
Blender includes a command line interface. The included arguments mostly have to do with rendering, but it also provides a flag to execute a Python expression, which makes its entire Python API available.
Here’s a one-liner that takes a .blend file and exports it to a binary glTF (.glb) file:
/Applications/Blender.app/Contents/MacOS/Blender -b input.blend \
  --python-expr "import bpy; bpy.ops.export_scene.gltf(filepath='output.glb')"- /Applications/Blender.app/Contents/MacOS/Blenderis the path to the Blender executable.
- -btells Blender to run headlessly.
- input.blendis the input file.
- --python-expris the command line flag that has Blender run the expression as Python.- import bpyimports the Blender library into the Python script.
- bpy.ops.export_scene.gltfis the Blender API function that exports the scene as a binary glTF.
- filepath='output.glb'tells Blender to save the exported file as- output.glb.