diff --git a/src/build123d/topology.py b/src/build123d/topology.py index 89d39a22..0a54791f 100644 --- a/src/build123d/topology.py +++ b/src/build123d/topology.py @@ -3650,6 +3650,10 @@ def __or__(self, filter_by: Union[Axis, GeomType] = Axis.Z): """Filter by axis or geomtype operator |""" return self.filter_by(filter_by) + def __eq__(self, other: ShapeList): + """ShapeLists equality operator ==""" + return set(self) == set(other) + def __add__(self, other: ShapeList): """Combine two ShapeLists together operator +""" return ShapeList(list(self) + list(other)) diff --git a/tests/test_build_common.py b/tests/test_build_common.py index 94a67599..075a27fc 100644 --- a/tests/test_build_common.py +++ b/tests/test_build_common.py @@ -553,6 +553,14 @@ def test_shapes(self): Box(1, 1, 1) self.assertIsNone(test._shapes(Compound)) + def test_operators(self): + with BuildPart() as test: + Box(1, 1, 1) + self.assertEqual( + (test.faces() | Axis.Z).edges() & (test.faces() | Axis.Y).edges(), + (test.edges() | Axis.X) + ) + class TestValidateInputs(unittest.TestCase): def test_wrong_builder(self):