Lathe Operation

Lathe is a powerful operation to build 3D geometry from a sketch by rotating it around an axis. For instance, rotating a circle around an axis can produce a donut.

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

donut = Part()
s = Sketch(donut.yz())
center = Point(s, 40, 0)
circle = Circle(center, 20)
axis = Axis(Line(Point(s, 0, 0), Point(s, 0, 10)))
lathe = Lathe(circle, axis)
donut.add_operation(lathe)
donut.paint("beige")
show(donut)

You can also create more complex objects by drawing a bit more on the sketch and creating symmetrical objects, making sure the sketch is symmetrical around the axis of rotation.

Here, for example, is a sketch with a drawing of a push pin.

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

class PushPin:

    def __init__(self):
        self.part = Part()

    def get_sketch(self):
        sketch = Sketch(self.part.xz())

        sketch.pencil.line(0.6, 2)
        sketch.pencil.line(0, 9)
        sketch.pencil.line(4.5 - 0.6, 0)
        sketch.pencil.arc_to(2.3, 14, -3.2)
        sketch.pencil.line_to(3.3 / 2, 14 + 7.8)
        sketch.pencil.arc_to(7.3 / 2, 14 + 7.8 + 2.3, -2.3)
        sketch.pencil.line(-7.3 / 2, 0)

        shape = sketch.pencil.get_closed_shape()

        return sketch

show(PushPin().get_sketch())

By applying the operation, here’s what we get:

Renders the 3D model in your browser. The first run downloads the Python runtime (≈30 MB).
# %%
from cadbuildr.foundation import Part, Sketch, Lathe, Axis, Line, Point, show


class PushPin(Part):
    def __init__(self):
        shape, axis = self.get_sketch()
        # do the lathe.
        self.add_operation(Lathe(shape, axis))

    def get_sketch(self):
        sketch = Sketch(self.yz())
        sketch.pencil.line(0.6, 2)
        sketch.pencil.line(0, 9)
        sketch.pencil.line(4.5 - 0.6, 0)
        sketch.pencil.arc_to(2.3, 14, -3.2)
        sketch.pencil.line_to(3.3 / 2, 14 + 7.8)
        sketch.pencil.arc_to(7.3 / 2, 14 + 7.8 + 2.3, -2.3)
        sketch.pencil.line(-7.3 / 2, 0)

        shape = sketch.pencil.get_closed_shape()
        axis = Axis(Line(Point(sketch, 0, 0), Point(sketch, 0, 10)))
        return shape, axis


show(PushPin())

# %%