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

Method twistExtrude

cadquery/cq.py:2980–3028  ·  view source on GitHub ↗

Extrudes a wire in the direction normal to the plane, but also twists by the specified angle over the length of the extrusion. The center point of the rotation will be the center of the workplane. See extrude for more details, since this method is the same except f

(
        self: T,
        distance: float,
        angleDegrees: float,
        combine: CombineMode = True,
        clean: bool = True,
    )

Source from the content-addressed store, hash-verified

2978
2979 # TODO: duplicated code with _extrude and extrude
2980 def twistExtrude(
2981 self: T,
2982 distance: float,
2983 angleDegrees: float,
2984 combine: CombineMode = True,
2985 clean: bool = True,
2986 ) -> T:
2987 """
2988 Extrudes a wire in the direction normal to the plane, but also twists by the specified
2989 angle over the length of the extrusion.
2990
2991 The center point of the rotation will be the center of the workplane.
2992
2993 See extrude for more details, since this method is the same except for the the addition
2994 of the angle. In fact, if angle=0, the result is the same as a linear extrude.
2995
2996 **NOTE** This method can create complex calculations, so be careful using it with
2997 complex geometries
2998
2999 :param distance: the distance to extrude normal to the workplane
3000 :param angle: angle (in degrees) to rotate through the extrusion
3001 :param combine: True or "a" to combine the resulting solid with parent solids if found,
3002 "cut" or "s" to remove the resulting solid from the parent solids if found.
3003 False to keep the resulting solid separated from the parent solids.
3004 :param clean: call :meth:`clean` afterwards to have a clean shape
3005 :return: a CQ object with the resulting solid selected.
3006 """
3007 faces = self._getFaces()
3008
3009 # compute extrusion vector and extrude
3010 eDir = self.plane.zDir.multiply(distance)
3011
3012 # one would think that fusing faces into a compound and then extruding would work,
3013 # but it doesn't-- the resulting compound appears to look right, ( right number of faces, etc)
3014 # but then cutting it from the main solid fails with BRep_NotDone.
3015 # the work around is to extrude each and then join the resulting solids, which seems to work
3016
3017 # underlying cad kernel can only handle simple bosses-- we'll aggregate them if there
3018 # are multiple sets
3019 shapes: List[Shape] = []
3020 for f in faces:
3021 thisObj = Solid.extrudeLinearWithRotation(
3022 f, self.plane.origin, eDir, angleDegrees
3023 )
3024 shapes.append(thisObj)
3025
3026 r = Compound.makeCompound(shapes).fuse()
3027
3028 return self._combineWithBase(r, combine, clean)
3029
3030 def extrude(
3031 self: T,

Callers 3

testTwistExtrudeMethod · 0.80

Calls 7

_getFacesMethod · 0.95
_combineWithBaseMethod · 0.95
appendMethod · 0.80
makeCompoundMethod · 0.80
multiplyMethod · 0.45
fuseMethod · 0.45

Tested by 3

testTwistExtrudeMethod · 0.64