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

Method _extrude

cadquery/cq.py:3689–3798  ·  view source on GitHub ↗

Make a prismatic solid from the existing set of pending wires. :param distance: distance to extrude :param both: extrude in both directions symmetrically :param upToFace: if specified, extrude up to a face: 0 for the next, -1 for the last face :param additiv

(
        self,
        distance: Optional[float] = None,
        both: bool = False,
        taper: Optional[float] = None,
        upToFace: Optional[Union[int, Face]] = None,
        additive: bool = True,
    )

Source from the content-addressed store, hash-verified

3687 return rv
3688
3689 def _extrude(
3690 self,
3691 distance: Optional[float] = None,
3692 both: bool = False,
3693 taper: Optional[float] = None,
3694 upToFace: Optional[Union[int, Face]] = None,
3695 additive: bool = True,
3696 ) -> Union[Solid, Compound]:
3697 """
3698 Make a prismatic solid from the existing set of pending wires.
3699
3700 :param distance: distance to extrude
3701 :param both: extrude in both directions symmetrically
3702 :param upToFace: if specified, extrude up to a face: 0 for the next, -1 for the last face
3703 :param additive: specify if extruding or cutting, required param for uptoface algorithm
3704
3705 :return: OCCT solid(s), suitable for boolean operations.
3706
3707 This method is a utility method, primarily for plugin and internal use.
3708 It is the basis for cutBlind, extrude, cutThruAll, and all similar methods.
3709 """
3710
3711 def getFacesList(face, eDir, direction, both=False):
3712 """
3713 Utility function to make the code further below more clean and tidy
3714 Performs some test and raise appropriate error when no Faces are found for extrusion
3715 """
3716 facesList = self.findSolid().facesIntersectedByLine(
3717 face.Center(), eDir, direction=direction
3718 )
3719 if len(facesList) == 0 and both:
3720 raise ValueError(
3721 "Couldn't find a face to extrude/cut to for at least one of the two required directions of extrusion/cut."
3722 )
3723
3724 if len(facesList) == 0:
3725 # if we don't find faces in the workplane normal direction we try the other
3726 # direction (as the user might have created a workplane with wrong orientation)
3727 facesList = self.findSolid().facesIntersectedByLine(
3728 face.Center(), eDir.multiply(-1.0), direction=direction
3729 )
3730 if len(facesList) == 0:
3731 raise ValueError(
3732 "Couldn't find a face to extrude/cut to. Check your workplane orientation."
3733 )
3734 return facesList
3735
3736 # process sketches or pending wires
3737 faces = self._getFaces()
3738
3739 # check for nested geometry and tapered extrusion
3740 for face in faces:
3741 if taper and face.innerWires():
3742 raise ValueError("Inner wires not allowed with tapered extrusion")
3743
3744 # compute extrusion vector and extrude
3745 if upToFace is not None:
3746 eDir = self.plane.zDir

Callers 3

extrudeMethod · 0.95
cutBlindMethod · 0.95
splitMethod · 0.80

Calls 12

_getFacesMethod · 0.95
findSolidMethod · 0.95
innerWiresMethod · 0.80
outerWireMethod · 0.80
dprismMethod · 0.80
extrudeLinearMethod · 0.80
appendMethod · 0.80
makeCompoundMethod · 0.80
multiplyMethod · 0.45
isInsideMethod · 0.45
CenterMethod · 0.45
fuseMethod · 0.45

Tested by

no test coverage detected