FoundationPartsSheet MetalContour Flange

Contour Flange

SheetMetalContourFlange(points, extent, thickness) builds a whole sheet-metal body from one open profile — the quickest way to make channels, Z / hat sections and brackets. points is the polyline of the mold line drawn on a sketch; it is swept extent along the sketch normal, and every corner becomes a bend with inside radius default_bend_radius.

direction puts the material on the left of the direction of travel (POSITIVE, the default), on the right (NEGATIVE) or centred (SYMMETRIC).

Each straight segment becomes its own flange, so the body unfolds (right, orange), takes cuts and accepts more edge flanges like any other sheet-metal body.

from cadbuildr.foundation import (
    Assembly,
    Part,
    Point,
    SheetMetalContourFlange,
    SheetMetalToSolid,
    Sketch,
    Unfold,
    show,
)


class _HatSection(Part):
    """A hat section from ONE open profile: feet, walls and top in one go."""

    def __init__(self, flatten=False, extent=60, thickness=2):
        s = Sketch(self.xz())
        profile = [
            Point(s, -30, 0),
            Point(s, -15, 0),
            Point(s, -15, 20),
            Point(s, 15, 20),
            Point(s, 15, 0),
            Point(s, 30, 0),
        ]
        body = SheetMetalContourFlange(profile, extent, thickness)
        if flatten:
            body = Unfold(body=body)
        self.add_operation(SheetMetalToSolid(body=body))
        self.paint("orange" if flatten else "light_blue")


class SheetMetalContourHat(Assembly):
    """SheetMetalContourFlange — the hat section (left) and its flat pattern (right)."""

    def __init__(self, separation=80):
        folded = _HatSection(flatten=False)
        folded.translate([-separation / 2, 0, 0])
        self.add_component(folded)
        flat = _HatSection(flatten=True)
        flat.translate([separation, 0, 0])
        self.add_component(flat)


show(SheetMetalContourHat())