MCPcopy
hub / github.com/CadQuery/cadquery / intersect

Method intersect

cadquery/cq.py:3429–3463  ·  view source on GitHub ↗

Intersects the provided solid from the current solid. :param toIntersect: a solid object, or a Workplane object having a solid :param clean: call :meth:`clean` afterwards to have a clean shape :param tol: tolerance value for fuzzy bool operation mode (default None)

(
        self: T,
        toIntersect: Union["Workplane", Solid, Compound],
        clean: bool = True,
        tol: Optional[float] = None,
    )

Source from the content-addressed store, hash-verified

3427 return self.cut(other)
3428
3429 def intersect(
3430 self: T,
3431 toIntersect: Union["Workplane", Solid, Compound],
3432 clean: bool = True,
3433 tol: Optional[float] = None,
3434 ) -> T:
3435 """
3436 Intersects the provided solid from the current solid.
3437
3438 :param toIntersect: a solid object, or a Workplane object having a solid
3439 :param clean: call :meth:`clean` afterwards to have a clean shape
3440 :param tol: tolerance value for fuzzy bool operation mode (default None)
3441 :raises ValueError: if there is no solid to intersect with in the chain
3442 :return: a Workplane object with the resulting object selected
3443 """
3444
3445 # look for parents to intersect with
3446 solidRef = self.findSolid(searchStack=True, searchParents=True)
3447
3448 solidToIntersect: Sequence[Shape]
3449
3450 if isinstance(toIntersect, Workplane):
3451 solidToIntersect = _selectShapes(toIntersect.vals())
3452 self._mergeTags(toIntersect)
3453 elif isinstance(toIntersect, (Solid, Compound)):
3454 solidToIntersect = (toIntersect,)
3455 else:
3456 raise ValueError("Cannot intersect type '{}'".format(type(toIntersect)))
3457
3458 newS = solidRef.intersect(*solidToIntersect, tol=tol)
3459
3460 if clean:
3461 newS = newS.clean()
3462
3463 return self.newObject([newS])
3464
3465 @deprecate()
3466 def __and__(self: T, other: Union["Workplane", Solid, Compound]) -> T:

Callers 8

__and__Method · 0.95
__mul__Method · 0.95
eachMethod · 0.45
sectionMethod · 0.45
test_dxf_textFunction · 0.45
testIntersectMethod · 0.45
testFuzzyBoolOpMethod · 0.45
test_MergeTagsMethod · 0.45

Calls 6

findSolidMethod · 0.95
_mergeTagsMethod · 0.95
newObjectMethod · 0.95
_selectShapesFunction · 0.85
valsMethod · 0.45
cleanMethod · 0.45

Tested by 4

test_dxf_textFunction · 0.36
testIntersectMethod · 0.36
testFuzzyBoolOpMethod · 0.36
test_MergeTagsMethod · 0.36