FoundationPartsSheet MetalFold & partial refold

Fold & partial refold

SheetMetalFold(body=Unfold(...)) folds a flat pattern back up. With no selection every bend is refolded, and you get the original part back.

Pass refold=[...] with the flange operations (SheetMetalEdgeFlange, SheetMetalHem, …) whose bends should be folded again. All the other bends stay flat. The three channels above are the folded part (blue), its flat pattern (orange), and the flat pattern with only the front wall refolded (green): the press-brake state after the first hit.

In a partial refold, each flat bend is the bend-allowance strip of the flat pattern, and each refolded bend is its true inside-radius arc. Selecting bends by kernel id (bend_ids=[...]) works too.

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


class _Channel(Part):
    """A U-channel: two 25 mm walls bent up from a 80 × 40 base.

    stage = "folded" | "flat" | "partial" (only the front wall bent: the
    press-brake state after the first hit).
    """

    def __init__(self, stage, width=80, depth=40, wall=25, thickness=2):
        s = Sketch(self.xy())
        base = SheetMetalBaseFlange(
            profile=Rectangle.from_center_and_sides(s.origin, width, depth), thickness=thickness
        )
        hw, hd = width / 2, depth / 2
        front = SheetMetalEdgeFlange(body=base, edge=Line(Point(s, -hw, -hd), Point(s, hw, -hd)), length=wall)
        back = SheetMetalEdgeFlange(body=front, edge=Line(Point(s, hw, hd), Point(s, -hw, hd)), length=wall)
        body = back
        if stage != "folded":
            body = Unfold(body=back)
        if stage == "partial":
            body = SheetMetalFold(body=body, refold=[front])
        self.add_operation(SheetMetalToSolid(body=body))
        self.paint({"folded": "light_blue", "flat": "dark_orange", "partial": "light_green"}[stage])


class PartialFold(Assembly):
    """Folded (left), flat pattern (middle) and partially refolded — front wall
    up, back wall still flat (right)."""

    def __init__(self):
        for i, stage in enumerate(["folded", "flat", "partial"]):
            c = _Channel(stage)
            c.translate([(i - 1) * 110, 0, 0])
            self.add_component(c)


show(PartialFold())