Pattern helpers

Renders the 3D model in your browser. The first run downloads the Python runtime (≈30 MB).
from cadbuildr.foundation import *


class PatternsPlate(Part):
    """Four pattern helpers — Grid, Hex, Polar, explicit Locations.

    All emit a list of sketch-anchored Points. Iterate to place N operations
    (through-holes here, but anything composes). The holes are drilled through
    the flat XY face so each pattern reads clearly on the plate.
    """

    def __init__(self):
        s = Sketch(self.xy())
        # Flat plate lying in the XY plane, 4 thick along Z.
        self.add_operation(Box(s.origin, w=120, d=120, h=4))
        # Drill the patterns through the plate's bottom face.
        face = Sketch(self.xy().get_parallel_plane(-2))

        # Grid: rectangular array (top-left).
        for p in GridLocations(Point(face, -35, 35), x_pitch=10, y_pitch=10, n_x=3, n_y=3).positions():
            self.add_operation(Hole(p, radius=1.5, depth=4))

        # Hex: centered-hex tiling (top-right).
        for p in HexLocations(Point(face, 35, 35), pitch=8, n_radial=3).positions():
            self.add_operation(Hole(p, radius=1.0, depth=4))

        # Polar: bolt circle (bottom-left).
        for p in PolarLocations(Point(face, -35, -25), radius=15, count=8).positions():
            self.add_operation(Hole(p, radius=1.5, depth=4))

        # Locations: explicit per-point offsets (bottom-right).
        offsets = [(-10, -10), (10, -10), (-10, 10), (10, 10), (0, 0)]
        for p in Locations(Point(face, 35, -25), offsets).positions():
            self.add_operation(Hole(p, radius=1.5, depth=4))

        self.paint("dark_tan")


show(PatternsPlate())

Pattern helpers are pure-Python factories that emit a list of sketch-anchored Points — iterate to place N operations.

GridLocations(center, x_pitch, y_pitch, n_x, n_y).positions() -> list[Point]
HexLocations(center, pitch, n_radial).positions() -> list[Point]
PolarLocations(center, radius, count, start_angle_deg=0, angular_range_deg=360).positions() -> list[Point]
Locations(center, [(dx, dy), ...]).positions() -> list[Point]

HexLocations(n_radial=k) produces a centered-hex tiling with 3·k²−3·k+1 points. PolarLocations uses range/count spacing for full circles and range/(count-1) for partial arcs.

These are helpers, not DAG nodes — they don’t show up in the serialized DAG, only the operations they produce do.