Surfaces

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


class WavePanel(Part):
    """ExtrudedSurface: an open spline pushed 40 mm, thickened to a 2 mm panel."""

    def __init__(self):
        s = Sketch(self.xz())
        wave = CustomOpenShape(
            [
                Spline(
                    [
                        Point(s, 0, 0),
                        Point(s, 10, 6),
                        Point(s, 20, 0),
                        Point(s, 30, -6),
                        Point(s, 40, 0),
                    ]
                )
            ]
        )
        self.add_operation(Thicken(ExtrudedSurface(wave, 40), 2))
        self.translate([-110, 0, 0])
        self.paint("light_blue")


class Bowl(Part):
    """RevolvedSurface: a quarter-circle profile revolved a full turn, thickened."""

    def __init__(self, radius=20):
        s = Sketch(self.xz())
        profile = CustomOpenShape(
            [
                Arc(
                    Point(s, radius, 0),
                    Point(s, radius * 0.7071, -radius * 0.7071),
                    Point(s, 0, -radius),
                )
            ]
        )
        axis = Axis(Line(Point(s, 0, -30), Point(s, 0, 10)))
        self.add_operation(Thicken(RevolvedSurface(profile, axis), 2))
        self.translate([-30, 20, 25])
        self.paint("dark_orange")


class RuledScoop(Part):
    """RuledSurface: straight lines from a flat edge to an arc 30 mm above it."""

    def __init__(self):
        bottom = Sketch(self.xy())
        top = Sketch(self.xy().get_parallel_plane(30))
        edge = CustomOpenShape([Line(Point(bottom, -15, 0), Point(bottom, 15, 0))])
        arc = CustomOpenShape(
            [Arc(Point(top, -15, 0), Point(top, 0, 12), Point(top, 15, 0))]
        )
        self.add_operation(Thicken(RuledSurface(edge, arc), 2))
        self.translate([30, 20, 0])
        self.paint("lime")


class Disc(Part):
    """PlanarSurface: the flat face inside a circle, thickened to a 3 mm disc."""

    def __init__(self):
        s = Sketch(self.xy())
        self.add_operation(Thicken(PlanarSurface(Circle(s.origin, 10)), 3))
        self.translate([80, 20, 0])
        self.paint("light_bluish_gray")


class SurfaceGallery(Assembly):
    def __init__(self):
        for part in (WavePanel(), Bowl(), RuledScoop(), Disc()):
            self.add_component(part)


show(SurfaceGallery())

Surface operations build zero-thickness sheets; Thicken turns any of them into a solid, Stitch joins several into one, and Enclose makes the solid that crossing, overhanging surfaces close off.

NodeBuilds
ExtrudedSurface(curve, distance)an open or closed curve pushed along its sketch normal
RevolvedSurface(curve, axis, angle=360)a curve revolved about an axis
RuledSurface(start, end)straight lines between two curves on different sketches
PlanarSurface(shape)the flat face inside a closed shape
SurfaceLoft(shapes)a smooth surface through several sections
FillSurface(curves, support=…)an N-sided patch filling a closed loop (G0 / G1)
BoundarySurface(curves)a patch bounded by 2–4 3D curves
OffsetSurface(surface, d)a sheet moved along its normal
ExtendSurface(surface, d)a sheet grown past its free edges

Open curves are CustomOpenShapes made of Line, Arc and Spline primitives. The last four are covered in Fill, Boundary, Offset & Extend.

from cadbuildr.foundation import *


class WavePanel(Part):
    """ExtrudedSurface: an open spline pushed 40 mm, thickened to a 2 mm panel."""

    def __init__(self):
        s = Sketch(self.xz())
        wave = CustomOpenShape(
            [
                Spline(
                    [
                        Point(s, 0, 0),
                        Point(s, 10, 6),
                        Point(s, 20, 0),
                        Point(s, 30, -6),
                        Point(s, 40, 0),
                    ]
                )
            ]
        )
        self.add_operation(Thicken(ExtrudedSurface(wave, 40), 2))
        self.translate([-110, 0, 0])
        self.paint("light_blue")


class Bowl(Part):
    """RevolvedSurface: a quarter-circle profile revolved a full turn, thickened."""

    def __init__(self, radius=20):
        s = Sketch(self.xz())
        profile = CustomOpenShape(
            [
                Arc(
                    Point(s, radius, 0),
                    Point(s, radius * 0.7071, -radius * 0.7071),
                    Point(s, 0, -radius),
                )
            ]
        )
        axis = Axis(Line(Point(s, 0, -30), Point(s, 0, 10)))
        self.add_operation(Thicken(RevolvedSurface(profile, axis), 2))
        self.translate([-30, 20, 25])
        self.paint("dark_orange")


class RuledScoop(Part):
    """RuledSurface: straight lines from a flat edge to an arc 30 mm above it."""

    def __init__(self):
        bottom = Sketch(self.xy())
        top = Sketch(self.xy().get_parallel_plane(30))
        edge = CustomOpenShape([Line(Point(bottom, -15, 0), Point(bottom, 15, 0))])
        arc = CustomOpenShape(
            [Arc(Point(top, -15, 0), Point(top, 0, 12), Point(top, 15, 0))]
        )
        self.add_operation(Thicken(RuledSurface(edge, arc), 2))
        self.translate([30, 20, 0])
        self.paint("lime")


class Disc(Part):
    """PlanarSurface: the flat face inside a circle, thickened to a 3 mm disc."""

    def __init__(self):
        s = Sketch(self.xy())
        self.add_operation(Thicken(PlanarSurface(Circle(s.origin, 10)), 3))
        self.translate([80, 20, 0])
        self.paint("light_bluish_gray")


class SurfaceGallery(Assembly):
    def __init__(self):
        for part in (WavePanel(), Bowl(), RuledScoop(), Disc()):
            self.add_component(part)


show(SurfaceGallery())