MCPcopy Index your code
hub / github.com/CadQuery/cadquery / extrudeLinearWithRotation

Method extrudeLinearWithRotation

cadquery/occ_impl/shapes.py:4374–4433  ·  view source on GitHub ↗

Creates a 'twisted prism' by extruding, while simultaneously rotating around the extrusion vector. Though the signature may appear to be similar enough to extrudeLinear to merit combining them, the construction methods used here are different enough that they should be sepa

(
        cls,
        outerWire: Wire,
        innerWires: list[Wire],
        vecCenter: VectorLike,
        vecNormal: VectorLike,
        angleDegrees: Real,
    )

Source from the content-addressed store, hash-verified

4372 @mypyclassmethod
4373 @multimethod
4374 def extrudeLinearWithRotation(
4375 cls,
4376 outerWire: Wire,
4377 innerWires: list[Wire],
4378 vecCenter: VectorLike,
4379 vecNormal: VectorLike,
4380 angleDegrees: Real,
4381 ) -> Solid:
4382 """
4383 Creates a 'twisted prism' by extruding, while simultaneously rotating around the extrusion vector.
4384
4385 Though the signature may appear to be similar enough to extrudeLinear to merit combining them, the
4386 construction methods used here are different enough that they should be separate.
4387
4388 At a high level, the steps followed are:
4389
4390 (1) accept a set of wires
4391 (2) create another set of wires like this one, but which are transformed and rotated
4392 (3) create a ruledSurface between the sets of wires
4393 (4) create a shell and compute the resulting object
4394
4395 :param outerWire: the outermost wire
4396 :param innerWires: a list of inner wires
4397 :param vecCenter: the center point about which to rotate. the axis of rotation is defined by
4398 vecNormal, located at vecCenter.
4399 :param vecNormal: a vector along which to extrude the wires
4400 :param angleDegrees: the angle to rotate through while extruding
4401 :return: a Solid object
4402 """
4403
4404 vecNormal_ = Vector(vecNormal)
4405 vecCenter_ = Vector(vecCenter)
4406
4407 # make straight spine
4408 straight_spine_e = Edge.makeLine(vecCenter_, vecCenter_.add(vecNormal_))
4409 straight_spine_w = Wire.combine([straight_spine_e,])[0].wrapped
4410
4411 # make an auxiliary spine
4412 pitch = 360.0 / angleDegrees * vecNormal_.Length
4413 radius = 1
4414 aux_spine_w = Wire.makeHelix(
4415 pitch, vecNormal_.Length, radius, center=vecCenter_, dir=vecNormal_
4416 ).wrapped
4417
4418 # extrude the outer wire
4419 outer_solid = cls._extrudeAuxSpine(
4420 outerWire.wrapped, straight_spine_w, aux_spine_w
4421 )
4422
4423 # extrude inner wires
4424 inner_solids = [
4425 cls._extrudeAuxSpine(w.wrapped, straight_spine_w, aux_spine_w)
4426 for w in innerWires
4427 ]
4428
4429 # combine the inner solids into compound
4430 inner_comp = Compound._makeCompound(inner_solids)
4431

Callers 1

twistExtrudeMethod · 0.80

Calls 9

addMethod · 0.95
VectorClass · 0.85
makeLineMethod · 0.80
makeHelixMethod · 0.80
_extrudeAuxSpineMethod · 0.80
_makeCompoundMethod · 0.80
outerWireMethod · 0.80
innerWiresMethod · 0.80
combineMethod · 0.45

Tested by

no test coverage detected