FoundationPartsSheet MetalUnfold

Unfold

The Unfold node computes the flat pattern of a sheet-metal body — the shape it would have if every bend were flattened. The assembly above shows the same bracket twice: folded (left, blue) next to its unfolded flat pattern (right, orange), so you can see each 90° bend trade for a flat bend-allowance strip.

Each bend contributes its neutral-fibre arc length: (radius + k_factor * thickness) * angle. The result is itself a sheet-metal body, with bend lines preserved as marked edges, ready to feed into a DXF exporter.

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


class _Bracket(Part):
    """One L-bracket — folded, or unfolded to its flat pattern."""

    def __init__(self, flatten=False, width=60, depth=40, thickness=2, wall_height=20):
        s = Sketch(self.xy())
        base = SheetMetalBaseFlange(
            profile=Rectangle.from_center_and_sides(s.origin, width, depth), thickness=thickness
        )
        front = Line(Point(s, -width / 2, -depth / 2), Point(s, width / 2, -depth / 2))
        body = SheetMetalEdgeFlange(body=base, edge=front, length=wall_height)
        if flatten:
            body = Unfold(body=body)
        self.add_operation(SheetMetalToSolid(body=body))
        self.paint("orange" if flatten else "light_blue")


class SheetMetalUnfoldComparison(Assembly):
    """The same bracket twice: folded (left, blue) next to its unfolded flat
    pattern (right, orange)."""

    def __init__(self, separation=50):
        folded = _Bracket(flatten=False)
        folded.translate([-separation, 0, 0])
        self.add_component(folded)
        flat = _Bracket(flatten=True)
        flat.translate([separation, 0, 0])
        self.add_component(flat)


show(SheetMetalUnfoldComparison())