From ed9d050fe4e5fe14fa812f6d75b04ac903f4dccf Mon Sep 17 00:00:00 2001 From: Jasper Chan Date: Tue, 13 Jan 2026 11:46:00 -0800 Subject: [PATCH] feature: allow adding invalid meshes to Mesher --- src/build123d/mesher.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/build123d/mesher.py b/src/build123d/mesher.py index 5fb9a54..8e04276 100644 --- a/src/build123d/mesher.py +++ b/src/build123d/mesher.py @@ -370,6 +370,7 @@ class Mesher: mesh_type: MeshType = MeshType.MODEL, part_number: str | None = None, uuid_value: UUID | None = None, + allow_invalid: bool = False, ): """add_shape @@ -383,6 +384,7 @@ class Mesher: mesh_type (MeshType, optional): 3D printing use of mesh. Defaults to MeshType.MODEL. part_number (str, optional): part #. Defaults to None. uuid_value (uuid, optional): value from uuid package. Defaults to None. + allow_invalid (bool, optional): allow adding invalid meshes instead of throwing an error Raises: RuntimeError: 3mf mesh is invalid @@ -439,7 +441,10 @@ class Mesher: # Check mesh if not mesh_3mf.IsValid(): - raise RuntimeError("3mf mesh is invalid") + msg = "3mf mesh is invalid" + if not allow_invalid: + raise RuntimeError(msg) + warnings.warn(msg, stacklevel=2) if not mesh_3mf.IsManifoldAndOriented(): warnings.warn("3mf mesh is not manifold", stacklevel=2)