Skip to content

Instantly share code, notes, and snippets.

@JaldertVicarious
Created April 15, 2022 09:26
Show Gist options
  • Save JaldertVicarious/ee27cb77f9ad8786126709481492e1ab to your computer and use it in GitHub Desktop.
Save JaldertVicarious/ee27cb77f9ad8786126709481492e1ab to your computer and use it in GitHub Desktop.
A script to convert ASCII STL to binary STL
#!/usr/bin/env python3
import trimesh
from fire import Fire
from typing import Optional
import numpy as np
def convert_and_scale_stl(*, in_stl_path: str, out_stl_path: str, scale: Optional[float] = None):
mesh = trimesh.load(in_stl_path)
# Apply scale, if requested
if scale is not None:
mesh.apply_scale(scale)
with open(out_stl_path, 'wb') as fh:
mesh.export(out_stl_path)
if __name__ == "__main__":
Fire(convert_and_scale_stl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment