Rip

Renders the 3D model in your browser. The first run downloads the Python runtime (≈30 MB).
from cadbuildr.foundation import *


class RippedBox(Part):
    """Rip: an open box shelled to 2 mm walls, ripped along its four vertical
    corners with a 1 mm gap — the walls now only meet the base, so the box
    can be unfolded (e.g. by SheetMetalFromSolid) or opened like a carton."""

    def __init__(self, length=40, width=30, height=20, wall=2, gap=1.0):
        s = Sketch(self.xy())
        block = Extrusion(
            Rectangle.from_center_and_sides(s.origin, length, width), height
        )
        top = FaceFinder(rule=InPlaneFinderRule(self.xy(), height))
        box = Shell(block, wall, face_finder=top)
        hl, hw = length / 2, width / 2
        corners = EdgeFinder(
            rule=EitherFinderRule(
                [
                    ContainsPointFinderRule(Point3D(x, y, height / 2))
                    for x, y in [(hl, hw), (-hl, hw), (-hl, -hw), (hl, -hw)]
                ]
            )
        )
        self.add_operation(Rip(box, corners, gap))
        self.paint("light_blue")


class RippedTray(Part):
    """Rip along a curved edge: a shelled, round-ended tray is ripped along
    the arc where its right-hand rounded wall meets the floor. The slot
    follows the arc, so that wall now hangs from the straight side walls
    only, free along its whole bottom edge."""

    def __init__(self, straight=20, width=30, height=15, wall=2, gap=1.0):
        s = Sketch(self.xy())
        half = straight / 2
        outline = SlotCenterToCenter(Point(s, -half, 0), Point(s, half, 0), width)
        block = Extrusion(outline, height)
        top = FaceFinder(rule=InPlaneFinderRule(self.xy(), height))
        tray = Shell(block, wall, face_finder=top)
        # The outer bottom arc of the right-hand end passes through (half + r, 0, 0).
        arc = EdgeFinder(rule=ContainsPointFinderRule(Point3D(half + width / 2, 0, 0)))
        self.add_operation(Rip(tray, arc, gap))
        self.translate([0, 50, 0])
        self.paint("dark_orange")


class RipExamples(Assembly):
    def __init__(self):
        self.add_component(RippedBox())
        self.add_component(RippedTray())


show(RipExamples())

Rip(solid, edge_finder, gap=0.5) cuts a gap-wide slot along each selected edge of a thin-walled (shelled) solid. The slot sits in the surface that bisects the two faces meeting at the edge, so the walls come apart at that corner while the rest of the part stays intact. Straight, arc and other curved edges all work: along a curve, the slot follows the edge.

Above, an open box with 2 mm walls is ripped along its four vertical corners: each wall now only joins the base, like an unglued carton. The orange tray is ripped along one curved edge, the arc where its rounded end meets the floor. That wall now hangs from the straight side walls only. Rip a shelled solid before converting it to sheet metal (SheetMetalFromSolid), or to open a seam in any shelled part.

Select the edges with an EdgeFinder. A ContainsPointFinderRule per corner, combined with EitherFinderRule, picks exactly the outer corner edges.

from cadbuildr.foundation import *


class RippedBox(Part):
    """Rip: an open box shelled to 2 mm walls, ripped along its four vertical
    corners with a 1 mm gap — the walls now only meet the base, so the box
    can be unfolded (e.g. by SheetMetalFromSolid) or opened like a carton."""

    def __init__(self, length=40, width=30, height=20, wall=2, gap=1.0):
        s = Sketch(self.xy())
        block = Extrusion(
            Rectangle.from_center_and_sides(s.origin, length, width), height
        )
        top = FaceFinder(rule=InPlaneFinderRule(self.xy(), height))
        box = Shell(block, wall, face_finder=top)
        hl, hw = length / 2, width / 2
        corners = EdgeFinder(
            rule=EitherFinderRule(
                [
                    ContainsPointFinderRule(Point3D(x, y, height / 2))
                    for x, y in [(hl, hw), (-hl, hw), (-hl, -hw), (hl, -hw)]
                ]
            )
        )
        self.add_operation(Rip(box, corners, gap))
        self.paint("light_blue")


class RippedTray(Part):
    """Rip along a curved edge: a shelled, round-ended tray is ripped along
    the arc where its right-hand rounded wall meets the floor. The slot
    follows the arc, so that wall now hangs from the straight side walls
    only, free along its whole bottom edge."""

    def __init__(self, straight=20, width=30, height=15, wall=2, gap=1.0):
        s = Sketch(self.xy())
        half = straight / 2
        outline = SlotCenterToCenter(Point(s, -half, 0), Point(s, half, 0), width)
        block = Extrusion(outline, height)
        top = FaceFinder(rule=InPlaneFinderRule(self.xy(), height))
        tray = Shell(block, wall, face_finder=top)
        # The outer bottom arc of the right-hand end passes through (half + r, 0, 0).
        arc = EdgeFinder(rule=ContainsPointFinderRule(Point3D(half + width / 2, 0, 0)))
        self.add_operation(Rip(tray, arc, gap))
        self.translate([0, 50, 0])
        self.paint("dark_orange")


class RipExamples(Assembly):
    def __init__(self):
        self.add_component(RippedBox())
        self.add_component(RippedTray())


show(RipExamples())