Use __or__ & __and__

This commit is contained in:
Ruben
2021-01-16 10:58:51 +01:00
parent 278f5aa2d8
commit 583a46b78e
2 changed files with 8 additions and 8 deletions

View File

@ -2969,15 +2969,15 @@ class Workplane(object):
return self.newObject([r])
def __add__(self, toUnion: Union["Workplane", Solid, Compound]) -> "Workplane":
def __or__(self, toUnion: Union["Workplane", Solid, Compound]) -> "Workplane":
"""
Syntactic sugar for union.
Notice that `r = a + b` is equivalent to `r = a.union(b)`.
Notice that `r = a | b` is equivalent to `r = a.union(b)`.
Example::
Box = Workplane("XY").box(1, 1, 1, centered=(False, False, False))
Sphere = Workplane("XY").sphere(1)
result = Box + Sphere
result = Box | Sphere
"""
return self.union(toUnion)
@ -3064,16 +3064,16 @@ class Workplane(object):
return self.newObject([newS])
def __mul__(self, toUnion: Union["Workplane", Solid, Compound]) -> "Workplane":
def __and__(self, toUnion: Union["Workplane", Solid, Compound]) -> "Workplane":
"""
Syntactic sugar for intersect.
Notice that `r = a * b` is equivalent to `r = a.intersect(b)`.
Notice that `r = a & b` is equivalent to `r = a.intersect(b)`.
Example::
Box = Workplane("XY").box(1, 1, 1, centered=(False, False, False))
Sphere = Workplane("XY").sphere(1)
result = Box * Sphere
result = Box & Sphere
"""
return self.intersect(toUnion)

View File

@ -1338,7 +1338,7 @@ class TestCadQuery(BaseTest):
b1.intersect(b2.faces().val())
# Test syntactic sugar [__mul__ method]
sugar = b1 * b2
sugar = b1 & b2
self.assertEqual(resS.val().Volume(), sugar.val().Volume())
def testBoundingBox(self):
@ -2184,7 +2184,7 @@ class TestCadQuery(BaseTest):
resS.union(toUnion.faces().val())
# Test syntactic sugar [__add__ method]
sugar = currentS + toUnion
sugar = currentS | toUnion
self.assertEqual(resS.faces().size(), sugar.faces().size())
def testCombine(self):