FoundationPartsOperationsLoft & Sweep cuts

Loft & Sweep cuts

Loft, Sweep and MultiSectionSweep take cut=True, just like Extrusion and Lathe. The solid they would have created is removed from the part instead of added to it.

  • Lofted pocket: a square opening on the top face lofts down to a round floor.
  • Swept channel: a round profile is dragged along a Spline3D path lying on the top face. It carves a half-round groove out to the edge of the block.

The sweep profile is drawn around its sketch origin. Sweep moves that origin onto the start point of the path, so draw the profile centred on sketch.origin, not at its final position in space.

from cadbuildr.foundation import *


class CutFeatures(Part):
    """Material removal with a loft and a sweep (`cut=True`).

    A lofted pocket goes from a square opening on the top face down to a round
    floor, and a swept channel snakes from the middle of the block out to its
    edge.
    """

    def __init__(self, length=90, width=50, height=15):
        s = Sketch(self.xy())
        self.add_operation(
            Extrusion(Rectangle.from_center_and_sides(s.origin, length, width), height)
        )

        # Lofted pocket: square at the top face -> circle 10 mm lower.
        top = Sketch(self.xy().get_parallel_plane(height))
        floor = Sketch(self.xy().get_parallel_plane(height - 10))
        mouth = Square.from_center_and_side(Point(top, -25, 0), 24)
        bottom = Circle(Point(floor, -25, 0), 6)
        self.add_operation(Loft(shapes=[mouth, bottom], cut=True))

        # Swept channel: a round profile dragged along a curve on the top face.
        # Draw the profile around its sketch origin — Sweep places that origin
        # on the path's start point.
        side = Sketch(self.yz())
        profile = Circle(side.origin, 3)
        path = Spline3D(
            points=[
                Point3D(0, 0, height),
                Point3D(15, 10, height),
                Point3D(30, -10, height),
                Point3D(length / 2 + 2, 0, height),
            ]
        )
        self.add_operation(Sweep(profile=profile, path=path, cut=True))
        self.paint("light_grey")


show(CutFeatures())