1D curves

Renders the 3D model in your browser. The first run downloads the Python runtime (≈30 MB).
from cadbuildr.foundation import *
from cadbuildr.foundation.gen.models import (
    FilletPolyline, ThreePointArc, CustomClosedShape, Line,
)


class CurvesAssembly(Assembly):
    """1D curve primitives composed into closed extrudable shapes.

    `FilletPolyline(points, radius)` — open polyline with rounded interior
    corners; closed manually by appending a return line.
    `ThreePointArc(p1, p2, p3)` — combined with two straight legs to form
    a pie-slice closed shape.
    """

    def __init__(self):
        # Pie-slice using a ThreePointArc + two legs back to origin.
        class PieSlice(Part):
            def __init__(self):
                s = Sketch(self.xy())
                origin = Point(s, 0, 0)
                edge1 = Point(s, 10, 0)
                edge2 = Point(s, 0, 10)
                # Quarter arc from edge1 to edge2 via the 45° point.
                import math as _m
                mid = Point(s, 10 * _m.cos(_m.pi/4), 10 * _m.sin(_m.pi/4))
                arc = ThreePointArc(p1=edge1, p2=mid, p3=edge2).expand()
                slice_shape = CustomClosedShape(primitives=[
                    Line(p1=origin, p2=edge1),
                    arc,
                    Line(p1=edge2, p2=origin),
                ])
                self.add_operation(Extrusion(slice_shape, end=2))
                self.paint("light_green")

        # FilletPolyline closed into a rectangle with rounded corners.
        class FilletPoly(Part):
            def __init__(self):
                s = Sketch(self.xy())
                pts = [Point(s, x, y) for x, y in
                       [(0, 0), (12, 0), (12, 8), (0, 8)]]
                fp = FilletPolyline(points=pts, radius=2)
                # Close by appending a line back to the start.
                primitives = list(fp.primitives) + [Line(p1=pts[-1], p2=pts[0])]
                self.add_operation(Extrusion(
                    CustomClosedShape(primitives=primitives), end=2,
                ))
                self.translate([25, 0, 0])
                self.paint("medium_azure")

        self.add_component(PieSlice())
        self.add_component(FilletPoly())


show(CurvesAssembly())

Curve primitives. They compose into CustomOpenShape (sweep paths, profiles) or CustomClosedShape (extrudable boundaries):

Polyline(points)                                  # N-1 lines through N points
FilletPolyline(points, radius)                    # Polyline with rounded corners
 
ThreePointArc(p1, p2, p3)                         # 3-point arc
RadiusArc(p1, p3, radius)                         # 2-point arc + signed radius
CenterArc(center, radius, start_deg, end_deg)     # arc by center & angles
SagittaArc(p1, p3, sagitta)                       # 2-point arc + sagitta
TangentArc(p1, p3, tangent)                       # arc tangent to a direction at p1
JernArc(start, tangent, radius, arc_size_deg)     # tangent + radius + sweep
EllipticalCenterArc(center, x_r, y_r, s_deg, e_deg)
Helix2D(center, pitch, radius_outer, n_turns)     # 2D helix unrolled to a spline
 
Bezier([start, ctrl1, ..., end])                  # degree-N Bezier
BSpline(points, degree=3)                         # uniform B-spline
Spline(points, start_tangent=None, end_tangent=None)

TangentArc and JernArc are the build123d-style constructors — useful when you have one anchor and a direction rather than two anchor points. Both expand into a 3-point Arc so they can be used wherever an Arc is accepted.