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

Method cylinder

cadquery/cq.py:4084–4139  ·  view source on GitHub ↗

Returns a cylinder with the specified radius and height for each point on the stack :param height: The height of the cylinder :param radius: The radius of the cylinder :param direct: The direction axis for the creation of the cylinder :type direct: A three-t

(
        self: T,
        height: float,
        radius: float,
        direct: Union[Tuple[float, float, float], Vector] = Vector(0, 0, 1),
        angle: float = 360,
        centered: Union[bool, Tuple[bool, bool, bool]] = True,
        combine: CombineMode = True,
        clean: bool = True,
    )

Source from the content-addressed store, hash-verified

4082 return self.eachpoint(lambda loc: s.moved(loc), True, combine, clean)
4083
4084 def cylinder(
4085 self: T,
4086 height: float,
4087 radius: float,
4088 direct: Union[Tuple[float, float, float], Vector] = Vector(0, 0, 1),
4089 angle: float = 360,
4090 centered: Union[bool, Tuple[bool, bool, bool]] = True,
4091 combine: CombineMode = True,
4092 clean: bool = True,
4093 ) -> T:
4094 """
4095 Returns a cylinder with the specified radius and height for each point on the stack
4096
4097 :param height: The height of the cylinder
4098 :param radius: The radius of the cylinder
4099 :param direct: The direction axis for the creation of the cylinder
4100 :type direct: A three-tuple
4101 :param angle: The angle to sweep the cylinder arc through
4102 :type angle: float > 0
4103 :param centered: If True, the cylinder will be centered around the reference point. If False,
4104 the corner of a bounding box around the cylinder will be on the reference point and it
4105 will extend in the positive x, y and z directions. Can also use a 3-tuple to specify
4106 centering along each axis.
4107 :param combine: Whether the results should be combined with other solids on the stack
4108 (and each other)
4109 :type combine: true to combine shapes, false otherwise
4110 :param clean: call :meth:`clean` afterwards to have a clean shape
4111 :return: A cylinder object for each point on the stack
4112
4113 One cylinder is created for each item on the current stack. If no items are on the stack, one
4114 cylinder is created using the current workplane center.
4115
4116 If combine is true, the result will be a single object on the stack. If a solid was found
4117 in the chain, the result is that solid with all cylinders produced fused onto it otherwise,
4118 the result is the combination of all the produced cylinders.
4119
4120 If combine is false, the result will be a list of the cylinders produced.
4121 """
4122 if isinstance(centered, bool):
4123 centered = (centered, centered, centered)
4124
4125 offset = Vector()
4126 if not centered[0]:
4127 offset += Vector(radius, 0, 0)
4128 if not centered[1]:
4129 offset += Vector(0, radius, 0)
4130 if centered[2]:
4131 offset += Vector(0, 0, -height / 2)
4132
4133 # first center and then apply the direction
4134 s = Solid.makeCylinder(radius, height, offset, Vector(0, 0, 1), angle).moved(
4135 Plane(Vector(), normal=direct).location
4136 )
4137
4138 # We want a cylinder for each point on the workplane
4139 return self.eachpoint(lambda loc: s.moved(loc), True, combine, clean)
4140
4141 def wedge(

Callers 13

test_fused_assemblyFunction · 0.80
testCylinderDefaultsMethod · 0.80
testCylinderCenteringMethod · 0.80
testCleanMethod · 0.80
testNoCleanMethod · 0.80
test_MergeTagsMethod · 0.80
subshape_assyFunction · 0.80

Calls 5

eachpointMethod · 0.95
VectorClass · 0.85
PlaneClass · 0.85
makeCylinderMethod · 0.80
movedMethod · 0.45

Tested by 13

test_fused_assemblyFunction · 0.64
testCylinderDefaultsMethod · 0.64
testCylinderCenteringMethod · 0.64
testCleanMethod · 0.64
testNoCleanMethod · 0.64
test_MergeTagsMethod · 0.64
subshape_assyFunction · 0.64