Skip to content

Commit

Permalink
Warn on STL simplification failures (#4)
Browse files Browse the repository at this point in the history
It looks like Open3D occasionally doesn't like the STLs produced by OnShape and can't simplify them. For now, we'll be tolerant of this error since it appears to be a bug outside of our code.

Fixes #3
  • Loading branch information
velovix authored Jan 10, 2024
1 parent 35191fa commit d54f323
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion onshape_urdf_exporter/stl_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pathlib import Path

import open3d as o3d
from colorama import Fore, Style


def simplify_stl(path: Path) -> None:
Expand All @@ -20,11 +21,18 @@ def simplify_stl(path: Path) -> None:
simple_mesh = simple_mesh.compute_triangle_normals()
simple_mesh = simple_mesh.compute_vertex_normals()

assert o3d.io.write_triangle_mesh(
success = o3d.io.write_triangle_mesh(
str(path),
simple_mesh,
write_vertex_normals=False,
write_triangle_uvs=False,
compressed=False,
write_vertex_colors=False,
)
if not success:
print(
f"{Fore.YELLOW}"
f"WARNING: Failed to simplify STL {path}. See above logs for "
f"clues as to why."
f"{Style.RESET_ALL}"
)

0 comments on commit d54f323

Please sign in to comment.