Created
April 15, 2022 09:26
-
-
Save JaldertVicarious/ee27cb77f9ad8786126709481492e1ab to your computer and use it in GitHub Desktop.
A script to convert ASCII STL to binary STL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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