FoundationPartsSheet MetalCut

Cut

SheetMetalCut(body, profile) cuts a closed profile (a hole, slot or cut-out) straight through the sheet. The assembly above shows the same bracket folded (left, blue) and as its flat pattern (right, orange). The four mounting holes and the wall slot appear in both.

Draw the profile on a sketch that lies on either face of the flange you want to cut:

  • for the base flange, the XY plane (its bottom face) or the plane thickness above it;
  • for a wall, a plane coincident with the wall’s inner or outer face — here self.xz().get_parallel_plane(depth / 2).

Unlike an Extrusion(..., cut=True) applied after SheetMetalToSolid, a SheetMetalCut is remembered by the flange it goes through. Unfold lays the cut-out out with that flange, so it ends up in the right place on the flat pattern and in the DXF export as an inner contour. If the sketch doesn’t lie on any flange face, the cut fails with an error that lists each flange’s plane, so you can see which offset to use.

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


class _CutBracket(Part):
    """L-bracket with mounting holes in the base and a slot in the wall."""

    def __init__(self, flatten=False, width=60, depth=40, thickness=2, wall_height=24):
        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)

        # Four mounting holes, sketched on the base's bottom face (the XY plane).
        for x in (-20, 20):
            for y in (-5, 12):
                body = SheetMetalCut(body=body, profile=Circle(Point(s, x, y), 3))

        # A slot through the wall, sketched on the wall's outer face.
        wall_face = Sketch(self.xz().get_parallel_plane(depth / 2))
        slot = SlotCenterToCenter(
            Point(wall_face, -12, wall_height / 2 + 2),
            Point(wall_face, 12, wall_height / 2 + 2),
            6,
        )
        body = SheetMetalCut(body=body, profile=slot)

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


class SheetMetalCutBracket(Assembly):
    """SheetMetalCut — the same bracket folded (left) and as its flat pattern
    (right). The cut-outs follow the metal into the flat pattern and the DXF."""

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


show(SheetMetalCutBracket())