FoundationPartsOperationsPatterns (Linear & Polar)

Patterns (Linear & Polar)

LinearPattern(shape, direction, count, spacing) repeats a solid along a direction; PolarPattern(shape, count, angle=360) repeats it around an axis (Z through the origin by default — set axis_origin / axis_direction). The first copy is the original, so add only the pattern to the part.

Patterning a cutting feature patterns the cut: the six bolt holes above are a single Extrusion(..., cut=True) inside a PolarPattern. With the default angle=360 the copies are spread evenly; with a smaller angle the first and last copies sit at 0° and angle.

These are 3D patterns of solids. To repeat 2D shapes inside a sketch, see Sketch operations.

from cadbuildr.foundation import *


class BoltCircleFlange(Part):
    """LinearPattern and PolarPattern of solid features.

    Six bolt holes are one cut Extrusion repeated by a PolarPattern (the
    pattern inherits `cut=True`), and four stiffening ribs are one rib repeated
    by a LinearPattern.
    """

    def __init__(self, radius=40, thickness=8, holes=6, ribs=4):
        s = Sketch(self.xy())
        self.add_operation(Extrusion(Circle(s.origin, radius), thickness))

        hole = Extrusion(Circle(Point(s, 30, 0), 3), thickness, cut=True)
        self.add_operation(PolarPattern(hole, holes))

        top = Sketch(self.xy().get_parallel_plane(thickness))
        rib = Extrusion(Rectangle.from_center_and_sides(Point(top, -12, 0), 2, 30), 5)
        self.add_operation(LinearPattern(rib, Point3D(1, 0, 0), ribs, 8))
        self.paint("medium_azure")


show(BoltCircleFlange())