FoundationPartsOperationsFill, Boundary, Offset & Extend

Fill, Boundary, Offset & Extend surfaces

These operations build new sheets from curves or from other sheets. Like the other surfaces, the result has no thickness: Thicken makes a solid of it, Stitch welds it to other sheets (a closed set of sheets becomes a solid, an open one stays a sheet).

NodeBuilds
FillSurface(curves=[...], support=None, edge_finder=None, continuity=G0, points=[])a patch filling one closed loop of curves and/or free edges of a support sheet
BoundarySurface(curves)a patch whose boundary is 2 to 4 curves
OffsetSurface(surface, distance)the sheet moved along its normal
ExtendSurface(surface, distance)the sheet grown past its free edges

Curves are any Path3D (Spline3D, Helix3D). A straight 3D edge is a two-point Spline3D.

FillSurface

The boundary is chained into one closed loop from:

  • curves: free 3D curves, in any order and direction;
  • the free edges of support (a sheet such as a SurfaceLoft): all of them, or only those edge_finder picks. A tube has two free rims, so pick one.

continuity=SurfaceContinuity.G1 makes the patch tangent to the support along its edges, so a cap on a cone continues it into a dome instead of a flat lid. points=[Point3D(...)] are points the patch must pass through. If a G1 patch can’t turn far enough (a cap on a straight cylinder must start vertical), the kernel says so: add a point to give it room.

The patch’s normal follows the loop: the right-hand rule over the curves as given, or the side that continues the support sheet’s normal.

rim = EdgeFinder(InPlaneFinderRule(self.xy().get_parallel_plane(10)))
cap = FillSurface(support=cone, edge_finder=rim, continuity=SurfaceContinuity.G1)
self.add_operation(Stitch(surfaces=[cone, cap, base]))  # closed -> a solid

G2 (curvature) continuity is not available: the OpenCascade build in the kernel only exposes G0 and G1 for this filler.

BoundarySurface

  • curves that chain end to end into a closed loop (3 or 4 of them): the 3- or 4-sided patch they bound;
  • two separate curves: the surface spanning them (the other two sides are the straight lines joining their ends; it doesn’t matter which way each curve runs).

OffsetSurface

distance goes along the sheet’s normal, the same direction Thicken grows (a PlanarSurface’s normal is its sketch plane’s normal); a negative distance goes the other way. An open tube offset by d is a tube of radius r ± d.

ExtendSurface

  • a single flat sheet: its outline is offset outward in its plane, with sharp corners (a 20 × 10 rectangle extended by 5 is 30 × 20);
  • a curved sheet: each face must be a four-sided patch. Free sides go on along the same surface where it continues (planes, cylinders, cones, spheres, tori) and as a tangent strip where it ends (B-spline faces such as lofts).

Edges shared between two faces, and the seam of a closed tube, never move. Trimmed curved faces (a curved face with a non-rectangular outline) are an error.

from cadbuildr.foundation import *


def line3d(a, b):
    return Spline3D(points=[Point3D(*a), Point3D(*b)])


class DomedCan(Part):
    """FillSurface: a G1 cap continues a 45° cone into a smooth dome."""

    def __init__(self):
        bottom = Sketch(self.xy())
        top = Sketch(self.xy().get_parallel_plane(10))
        cone = SurfaceLoft(
            shapes=[Circle(bottom.origin, 20), Circle(top.origin, 10)], ruled=True
        )
        rim = EdgeFinder(InPlaneFinderRule(self.xy().get_parallel_plane(10)))
        cap = FillSurface(
            support=cone, edge_finder=rim, continuity=SurfaceContinuity.G1
        )
        base = PlanarSurface(Circle(bottom.origin, 20))
        self.add_operation(Stitch(surfaces=[cone, cap, base]))
        self.translate([-45, 0, 0])
        self.paint("light_blue")


class SaddlePanel(Part):
    """BoundarySurface: a 4-sided patch through four 3D edges, thickened 1 mm."""

    def __init__(self):
        c = [(-12, -12, 0), (12, -12, 6), (12, 12, 0), (-12, 12, 6)]
        edges = [line3d(c[i], c[(i + 1) % 4]) for i in range(4)]
        self.add_operation(Thicken(BoundarySurface(curves=edges), 1.0))
        self.paint("dark_orange")


class GrownShelf(Part):
    """ExtendSurface + OffsetSurface: a 20 x 10 sheet grown 5 mm, lifted 4 mm, thickened."""

    def __init__(self):
        s = Sketch(self.xy())
        sheet = PlanarSurface(Rectangle.from_center_and_sides(s.origin, 20, 10))
        grown = ExtendSurface(sheet, 5)
        self.add_operation(Thicken(OffsetSurface(grown, 4), 2))
        self.translate([45, 0, 0])
        self.paint("lime")


class SurfaceTools(Assembly):
    def __init__(self):
        for part in (DomedCan(), SaddlePanel(), GrownShelf()):
            self.add_component(part)


show(SurfaceTools())