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

Method revolve

cadquery/cq.py:3094–3156  ·  view source on GitHub ↗

Use all un-revolved wires in the parent chain to create a solid. :param angleDegrees: the angle to revolve through. :type angleDegrees: float, anything less than 360 degrees will leave the shape open :param axisStart: the start point of the axis of rotation

(
        self: T,
        angleDegrees: float = 360.0,
        axisStart: Optional[VectorLike] = None,
        axisEnd: Optional[VectorLike] = None,
        combine: CombineMode = True,
        clean: bool = True,
    )

Source from the content-addressed store, hash-verified

3092 return self._combineWithBase(r, combine, clean)
3093
3094 def revolve(
3095 self: T,
3096 angleDegrees: float = 360.0,
3097 axisStart: Optional[VectorLike] = None,
3098 axisEnd: Optional[VectorLike] = None,
3099 combine: CombineMode = True,
3100 clean: bool = True,
3101 ) -> T:
3102 """
3103 Use all un-revolved wires in the parent chain to create a solid.
3104
3105 :param angleDegrees: the angle to revolve through.
3106 :type angleDegrees: float, anything less than 360 degrees will leave the shape open
3107 :param axisStart: the start point of the axis of rotation
3108 :param axisEnd: the end point of the axis of rotation
3109 :param combine: True or "a" to combine the resulting solid with parent solids if found,
3110 "cut" or "s" to remove the resulting solid from the parent solids if found.
3111 False to keep the resulting solid separated from the parent solids.
3112 :param clean: call :meth:`clean` afterwards to have a clean shape
3113 :return: a CQ object with the resulting solid selected.
3114
3115 The returned object is always a CQ object, and depends on whether combine is True, and
3116 whether a context solid is already defined:
3117
3118 * if combine is False, the new value is pushed onto the stack.
3119 * if combine is true, the value is combined with the context solid if it exists,
3120 and the resulting solid becomes the new context solid.
3121
3122 .. note::
3123 Keep in mind that `axisStart` and `axisEnd` are defined relative to the current Workplane center position.
3124 So if for example you want to revolve a circle centered at (10,0,0) around the Y axis, be sure to either :meth:`move` (or :meth:`moveTo`)
3125 the current Workplane position or specify `axisStart` and `axisEnd` with the correct vector position.
3126 In this example (0,0,0), (0,1,0) as axis coords would fail.
3127 """
3128 # Make sure we account for users specifying angles larger than 360 degrees
3129 angleDegrees %= 360.0
3130
3131 # Compensate for OCCT not assuming that a 0 degree revolve means a 360 degree revolve
3132 angleDegrees = 360.0 if angleDegrees == 0 else angleDegrees
3133
3134 # The default start point of the vector defining the axis of rotation will be the origin
3135 # of the workplane
3136 if axisStart is None:
3137 axisStart = self.plane.toWorldCoords((0, 0)).toTuple()
3138 else:
3139 axisStart = self.plane.toWorldCoords(axisStart).toTuple()
3140
3141 # The default end point of the vector defining the axis of rotation should be along the
3142 # normal from the plane
3143 if axisEnd is None:
3144 # Make sure we match the user's assumed axis of rotation if they specified an start
3145 # but not an end
3146 if axisStart[1] != 0:
3147 axisEnd = self.plane.toWorldCoords((0, axisStart[1])).toTuple()
3148 else:
3149 axisEnd = self.plane.toWorldCoords((0, 1)).toTuple()
3150 else:
3151 axisEnd = self.plane.toWorldCoords(axisEnd).toTuple()

Callers 7

_revolveMethod · 0.45
testRevolveCylinderMethod · 0.45
testRevolveDonutMethod · 0.45
testRevolveConeMethod · 0.45
testRevolveCutMethod · 0.45
testRevolveErrorsMethod · 0.45

Calls 4

_revolveMethod · 0.95
_combineWithBaseMethod · 0.95
toWorldCoordsMethod · 0.80
toTupleMethod · 0.45

Tested by 5

testRevolveCylinderMethod · 0.36
testRevolveDonutMethod · 0.36
testRevolveConeMethod · 0.36
testRevolveCutMethod · 0.36
testRevolveErrorsMethod · 0.36