diff --git a/src/build123d/topology/two_d.py b/src/build123d/topology/two_d.py index 31750476..4eb05c2a 100644 --- a/src/build123d/topology/two_d.py +++ b/src/build123d/topology/two_d.py @@ -764,6 +764,11 @@ class Face(Mixin2D[TopoDS_Face]): inner_topods_wires = ( [w.wrapped for w in inner_wires] if inner_wires is not None else [] ) + if any( + not BRep_Tool.IsClosed_s(w) + for w in [outer_wire.wrapped] + inner_topods_wires + ): + raise ValueError("Face can only be created with closed wires") obj = _make_topods_face_from_wires(outer_wire.wrapped, inner_topods_wires) super().__init__( diff --git a/tests/test_direct_api/test_face.py b/tests/test_direct_api/test_face.py index fa60acf1..92b78d88 100644 --- a/tests/test_direct_api/test_face.py +++ b/tests/test_direct_api/test_face.py @@ -1280,8 +1280,16 @@ class TestFace(unittest.TestCase): self.assertTrue(isinstance(revolved, Shell)) self.assertAlmostEqual(revolved.edges().sort_by(Axis.Y)[-1].radius, 2, 5) + def test_open_wire(self): + perimeter = Polyline((0, 0), (1, 0), (1, 1), (0, 1)) + with self.assertRaises(ValueError): + Face(perimeter) -class TestAxesOfSymmetrySplitNone(unittest.TestCase): + with self.assertRaises(ValueError): + Face(Wire.make_circle(5), [perimeter]) + + +class TestAxesOfSysmmetrySplitNone(unittest.TestCase): def test_split_returns_none(self): # Create a rectangle face for testing. rect = Rectangle(10, 5).face()