FoundationPartsSheet MetalUnfold

Unfold

unfold computes the flat pattern of a sheet-metal body — the shape it would have if every bend were flattened. 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 *
from cadbuildr.foundation.sheet_metal import base_flange, edge_flange, unfold, to_solid


class SheetMetalUnfoldedBracket(Part):
    def __init__(self, width=60, depth=40, thickness=2, wall_height=20):
        s = Sketch(self.xy())
        plate = Rectangle.from_center_and_sides(s.origin, width, depth)
        base = base_flange(profile=plate, sketch=s, thickness=thickness)

        edge = EdgeFinder(rule=InPlaneFinderRule(plane=self.xy()))
        flange = edge_flange(base, edge_finder=edge, length=wall_height)

        # Round-trip through unfold to expose the flat pattern
        flat = unfold(flange)
        self.add_operation(to_solid(flat))


show(SheetMetalUnfoldedBracket())