A plate, step by step

Copy Markdown View Source
Mix.install([{:smith, "~> 0.2.0"}, {:kino, "~> 0.19.0"}])

First lesson

Build one plate, round its corners, drill a hole, and export it. No CAD background is assumed; the CAD concepts guide explains the terms.

Run cells in order. Lengths are millimeters and modeling angles are degrees. Each 3D preview supports orbit, zoom, and fullscreen.

Start with a blank

Lengths are millimeters. Each stage is a reusable recipe; evaluating one does not change any earlier stage. Drag the preview to rotate, scroll to zoom, or download PNG.

blank = Smith.box(60, 40, 5)
Smith.Kino.render(blank, label: "1 · Blank")

Round the corners

A fillet replaces a sharp edge with a rounded transition. Rounding the four vertical edges changes the plate's footprint while keeping its top and bottom flat.

Select the four vertical edges with a reusable query. Smith resolves the query against the body at this step; count: catches an unintended selection if you change the design. You can add filters to the query with a pipeline.

alias Smith.Selector
vertical = Selector.parallel(:z)
rounded = blank |> Smith.fillet(edges: vertical, count: 4, radius: 2)
Smith.Kino.render(rounded, label: "2 · Rounded corners")

Drill the plate

The top-face shortcut places the hole at the face's area-weighted center. This plate is symmetric, so that is its geometric center. For a fixed pattern of holes, use an explicit plane as in mechanical parts.

finished = rounded |> Smith.hole(on: :top, diameter: 8, through: :all)
{:ok, result} = Smith.evaluate(finished)
Smith.Kino.render(result, label: "3 · Through hole")

Check and export

The analytic volume is a rectangular plate minus four rounded corner cutouts and a cylindrical bore. Export additionally verifies topology, the printable mesh, and a STEP round trip. Inspect the returned paths for STL and 3MF.

{:ok, volume} = OCEx.volume(result.shape)
expected = (60 * 40 - (4 - :math.pi()) * 2 * 2 - :math.pi() * 4 * 4) * 5
true = abs(volume - expected) < 1.0e-6
{:ok, files} = Smith.export(result, "output/livebook", name: "plate", on_bed: true)
files