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

Method cut

cadquery/cq.py:3379–3413  ·  view source on GitHub ↗

Cuts the provided solid from the current solid, IE, perform a solid subtraction. :param toCut: 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

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

Source from the content-addressed store, hash-verified

3377 return self.union(other)
3378
3379 def cut(
3380 self: T,
3381 toCut: Union["Workplane", Solid, Compound],
3382 clean: bool = True,
3383 tol: Optional[float] = None,
3384 ) -> T:
3385 """
3386 Cuts the provided solid from the current solid, IE, perform a solid subtraction.
3387
3388 :param toCut: a solid object, or a Workplane object having a solid
3389 :param clean: call :meth:`clean` afterwards to have a clean shape
3390 :param tol: tolerance value for fuzzy bool operation mode (default None)
3391 :raises ValueError: if there is no solid to subtract from in the chain
3392 :return: a Workplane object with the resulting object selected
3393 """
3394
3395 # look for parents to cut from
3396 solidRef = self.findSolid(searchStack=True, searchParents=True)
3397
3398 solidToCut: Sequence[Shape]
3399
3400 if isinstance(toCut, Workplane):
3401 solidToCut = _selectShapes(toCut.vals())
3402 self._mergeTags(toCut)
3403 elif isinstance(toCut, (Solid, Compound)):
3404 solidToCut = (toCut,)
3405 else:
3406 raise ValueError("Cannot cut type '{}'".format(type(toCut)))
3407
3408 newS = solidRef.cut(*solidToCut, tol=tol)
3409
3410 if clean:
3411 newS = newS.clean()
3412
3413 return self.newObject([newS])
3414
3415 def __sub__(self: T, other: Union["Workplane", Solid, Compound]) -> T:
3416 """

Callers 14

__sub__Method · 0.95
eachMethod · 0.45
splitMethod · 0.45
cutEachMethod · 0.45
_cutFromBaseMethod · 0.45
cutBlindMethod · 0.45
testDXFMethod · 0.45
testCutMethod · 0.45
testCupMethod · 0.45
testEnclosureMethod · 0.45
testIsInsideSolidMethod · 0.45
testUnionCompoundMethod · 0.45

Calls 6

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

Tested by 8

testDXFMethod · 0.36
testCutMethod · 0.36
testCupMethod · 0.36
testEnclosureMethod · 0.36
testIsInsideSolidMethod · 0.36
testUnionCompoundMethod · 0.36
testFuzzyBoolOpMethod · 0.36
test_MergeTagsMethod · 0.36