Parametric CAD in Rust
I keep designing physical parts for our robots. Motor mounts, sensor brackets, wheel hubs. Every time, the workflow is the same: open a GUI CAD program, click around for an hour, export an STL, realize the bolt pattern is 2mm off, repeat.
I wanted to write my parts the way I write firmware. In Rust. With types. With version control. With the ability to change one number and regenerate everything.
So I built vcad.
cargo add vcad
The idea
A part is just geometry with a name. You create primitives, combine them with boolean operations, and export. That's it.
use vcad::{centered_cube, centered_cylinder, bolt_pattern}; let plate = centered_cube("plate", 120.0, 80.0, 5.0); let bore = centered_cylinder("bore", 15.0, 10.0, 64); let bolts = bolt_pattern(6, 50.0, 4.5, 10.0, 32); let part = plate - bore - bolts; part.write_stl("plate.stl").unwrap();
That minus sign is a real boolean difference. + is union. & is intersection. Operator overloads make CSG feel like arithmetic.
The plate above has a center bore, four corner mounting holes, and a six-bolt circle pattern. Twelve lines of code. One STL file. Done.
... continue reading