FoundationPartsOperationsEnclose

Enclose

Enclose(surfaces) builds the solid that a set of surfaces closes off. Unlike Stitch, the surfaces don’t have to meet edge to edge: they can cross each other and run past each other, and everything that sticks out of the closed-off region is trimmed away. Above, five flat sheets 60 mm square and an arched roof that overhangs on every side make a 30 × 20 mm block.

Enclose([surface, ...]) -> Enclose
  • Any surface operation works: PlanarSurface, ExtrudedSurface, RevolvedSurface, RuledSurface, SurfaceLoft.
  • Every side of the region needs a surface reaching right across it. If one is too short (a gap in a wall), there is no enclosed region and the kernel reports Enclose: the surfaces do not close off any region instead of returning a solid.
  • When the surfaces close off several regions (a box with an inner wall), the regions are fused into one solid.
  • A surface that pokes into the region without crossing it closes nothing off and leaves no trace in the solid.

Add the Enclose to the part like any other solid operation; it can then be filleted, shelled or combined with booleans.

from cadbuildr.foundation import *

SHEET = 60  # every sheet is far bigger than the block: Enclose trims the overhangs


class ArchedBlock(Part):
    """Enclose: a block with an arched roof, from oversized crossing surfaces."""

    def __init__(self):
        def wall(plane, offset):
            s = Sketch(plane.get_parallel_plane(offset))
            return PlanarSurface(
                Rectangle.from_center_and_sides(s.origin, SHEET, SHEET)
            )

        # Roof: an arc pushed right across the block (it overhangs on every side).
        s = Sketch(self.xz().get_parallel_plane(-SHEET / 2))
        arc = CustomOpenShape([Arc(Point(s, -30, 8), Point(s, 0, 16), Point(s, 30, 8))])
        roof = ExtrudedSurface(arc, SHEET)

        surfaces = [
            wall(self.xy(), 0),  # floor
            wall(self.yz(), -15),  # x = -15 and x = 15 walls
            wall(self.yz(), 15),
            wall(self.xz(), -10),  # y = -10 and y = 10 walls
            wall(self.xz(), 10),
            roof,
        ]
        self.add_operation(Enclose(surfaces))
        self.paint("light_blue")


show(ArchedBlock())