Add syntactic sugar for boolean operations

This commit is contained in:
Ruben
2021-01-07 15:42:24 +01:00
parent f4b5e8210b
commit 33286c2a60
2 changed files with 42 additions and 0 deletions

View File

@ -1306,6 +1306,10 @@ class TestCadQuery(BaseTest):
with self.assertRaises(ValueError):
currentS.cut(toCut.faces().val())
# Test syntactic sugar [__sub__ method]
sugar = currentS - toCut.val()
self.assertEqual(resS.faces().size(), sugar.faces().size())
def testIntersect(self):
"""
Tests the intersect function.
@ -1333,6 +1337,10 @@ class TestCadQuery(BaseTest):
with self.assertRaises(ValueError):
b1.intersect(b2.faces().val())
# Test syntactic sugar [__mul__ method]
sugar = b1 * b2
self.assertEqual(resS.val().Volume(), sugar.val().Volume())
def testBoundingBox(self):
"""
Tests the boudingbox center of a model
@ -2175,6 +2183,10 @@ class TestCadQuery(BaseTest):
with self.assertRaises(ValueError):
resS.union(toUnion.faces().val())
# Test syntactic sugar [__add__ method]
sugar = currentS + toUnion
self.assertEqual(resS.faces().size(), sugar.faces().size())
def testCombine(self):
s = Workplane(Plane.XY())
objects1 = s.rect(2.0, 2.0).extrude(0.5).faces(">Z").rect(1.0, 1.0).extrude(0.5)