FoundationPartsSheet MetalChaining Flanges

Chaining Flanges

A flange can be bent off another flange, not only off the base. Point the edge flange at the flange you want to continue from with EdgeRef(flange=<operation>). The kernel finds that flange’s edge in 3D, so you don’t have to compute where the wall ended up.

flange_edgeEdge
FREE (default)the edge opposite the bend, e.g. the top of a wall
START_SIDE / END_SIDEthe two side edges of the flange

Passing the operation itself as the edge (edge=wall_r) is shorthand for its FREE edge.

A flange folds toward the bend side of the face it starts from. That makes the default a lipped C-channel; use a negative bend_angle to fold to the other side. The hat channel above uses bend_angle=-90 for its outward feet.

The flat pattern (right, orange) lays out every flange next to the flange it was bent from: web, wall, foot, each separated by its bend allowance (radius + k_factor * thickness) * angle.

from cadbuildr.foundation import (
    Assembly,
    EdgeRef,
    Line,
    Part,
    Point,
    Rectangle,
    SheetMetalBaseFlange,
    SheetMetalEdgeFlange,
    SheetMetalToSolid,
    Sketch,
    Unfold,
    show,
)


class _HatChannel(Part):
    """Hat channel: a web, two walls bent off the web, and two feet bent off
    the walls' free edges."""

    def __init__(self, flatten=False, length=80, web=30, wall=20, foot=12, thickness=2):
        s = Sketch(self.xy())
        body = SheetMetalBaseFlange(
            profile=Rectangle.from_center_and_sides(s.origin, length, web),
            thickness=thickness,
        )
        left = Line(Point(s, -length / 2, -web / 2), Point(s, length / 2, -web / 2))
        right = Line(Point(s, length / 2, web / 2), Point(s, -length / 2, web / 2))
        wall_l = SheetMetalEdgeFlange(body=body, edge=left, length=wall)
        wall_r = SheetMetalEdgeFlange(body=wall_l, edge=right, length=wall)

        # Feet hang off each wall's FREE edge (the edge opposite its bend).
        # `edge=EdgeRef(flange=wall_l)` is the explicit form; passing the
        # operation itself (`edge=wall_r`) means the same thing.
        foot_l = SheetMetalEdgeFlange(
            body=wall_r, edge=EdgeRef(flange=wall_l), length=foot, bend_angle=-90
        )
        body = SheetMetalEdgeFlange(
            body=foot_l, edge=wall_r, length=foot, bend_angle=-90
        )

        if flatten:
            body = Unfold(body=body)
        self.add_operation(SheetMetalToSolid(body=body))
        self.paint("orange" if flatten else "light_blue")


class SheetMetalHatChannel(Assembly):
    """Flange-off-flange chaining: the hat channel folded (left) and its flat
    pattern (right). Every flange lands in the flat pattern next to the flange
    it was bent from."""

    def __init__(self, separation=70):
        # Channels run along Y so the default camera looks down the hat profile.
        folded = _HatChannel(flatten=False)
        folded.rotate(90)
        folded.translate([-separation, 0, 0])
        self.add_component(folded)
        flat = _HatChannel(flatten=True)
        flat.rotate(90)
        flat.translate([separation / 2, 0, 0])
        self.add_component(flat)


show(SheetMetalHatChannel())