Use __or__ & __and__
This commit is contained in:
@ -2969,15 +2969,15 @@ class Workplane(object):
|
|||||||
|
|
||||||
return self.newObject([r])
|
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.
|
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::
|
Example::
|
||||||
Box = Workplane("XY").box(1, 1, 1, centered=(False, False, False))
|
Box = Workplane("XY").box(1, 1, 1, centered=(False, False, False))
|
||||||
Sphere = Workplane("XY").sphere(1)
|
Sphere = Workplane("XY").sphere(1)
|
||||||
result = Box + Sphere
|
result = Box | Sphere
|
||||||
"""
|
"""
|
||||||
return self.union(toUnion)
|
return self.union(toUnion)
|
||||||
|
|
||||||
@ -3064,16 +3064,16 @@ class Workplane(object):
|
|||||||
|
|
||||||
return self.newObject([newS])
|
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.
|
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::
|
Example::
|
||||||
|
|
||||||
Box = Workplane("XY").box(1, 1, 1, centered=(False, False, False))
|
Box = Workplane("XY").box(1, 1, 1, centered=(False, False, False))
|
||||||
Sphere = Workplane("XY").sphere(1)
|
Sphere = Workplane("XY").sphere(1)
|
||||||
result = Box * Sphere
|
result = Box & Sphere
|
||||||
"""
|
"""
|
||||||
return self.intersect(toUnion)
|
return self.intersect(toUnion)
|
||||||
|
|
||||||
|
@ -1338,7 +1338,7 @@ class TestCadQuery(BaseTest):
|
|||||||
b1.intersect(b2.faces().val())
|
b1.intersect(b2.faces().val())
|
||||||
|
|
||||||
# Test syntactic sugar [__mul__ method]
|
# Test syntactic sugar [__mul__ method]
|
||||||
sugar = b1 * b2
|
sugar = b1 & b2
|
||||||
self.assertEqual(resS.val().Volume(), sugar.val().Volume())
|
self.assertEqual(resS.val().Volume(), sugar.val().Volume())
|
||||||
|
|
||||||
def testBoundingBox(self):
|
def testBoundingBox(self):
|
||||||
@ -2184,7 +2184,7 @@ class TestCadQuery(BaseTest):
|
|||||||
resS.union(toUnion.faces().val())
|
resS.union(toUnion.faces().val())
|
||||||
|
|
||||||
# Test syntactic sugar [__add__ method]
|
# Test syntactic sugar [__add__ method]
|
||||||
sugar = currentS + toUnion
|
sugar = currentS | toUnion
|
||||||
self.assertEqual(resS.faces().size(), sugar.faces().size())
|
self.assertEqual(resS.faces().size(), sugar.faces().size())
|
||||||
|
|
||||||
def testCombine(self):
|
def testCombine(self):
|
||||||
|
Reference in New Issue
Block a user