FoundationPartsOperationsRip

Rip

Rip(solid, edge_finder, gap=0.5) cuts a gap-wide slot along each selected straight edge of a thin-walled (shelled) solid. The slot sits in the plane 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.

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. 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")


show(RippedBox())