Anvil – A 3D CAD modeling crate with predictable APIs, unit safety, and OpenCascade backend
Hey folks!
I've been working on a Rust crate called Anvil that aims to make 3D CAD modeling intuitive and reliable. It's early-stage and built on top of opencascade-sys, but we've added a lot of structure and consistency to the modeling workflow.
What is Anvil?
Anvil is a 3D and 2D modeling crate focused on:
- Consistent APIs: Similar interfaces between 2D and 3D operations (e.g., add, subtract, intersect)
- Mandatory units: All lengths and angles require explicit units (e.g., length!(16 mm)), avoiding hidden assumptions
- Tested by design: Almost all public APIs are tested, ensuring correctness and maintainability
Example: Making a LEGO brick in code
Here’s how you’d build a simple 2x2 LEGO-style block:
let block_width = length!(16 mm);
let block_height = length!(9.6 mm);
let stud_height = length!(11.2 mm) - block_height;
let stud_distance = length!(8 mm);
let stud_diameter = length!(4.8 mm);
let block = Cuboid::from_dim(block_width, block_width, block_height);
let studs = Cylinder::from_diameter(stud_diameter, stud_height)
.move_to(Point3D::new(
stud_distance / 2.,
stud_distance / 2.,
(block_height + stud_height) / 2.,
))
.circular_pattern(Axis::z(), 4);
let part = block.add(&studs);
// see full example and result in the README
Why Anvil?
We initially used opencascade-rs for another project but ran into a few blockers:
- Missing basic traits like
CloneorPartialEq - Lack of documentation and tests
- Inconsistent and unintuitive APIs
So we built Anvil on top of opencascade-sys, wrapping it with a safer, more ergonomic Rust interface.
Would love feedback on
- API design: Is it idiomatic? Any major smells?
- Missing features you would expect in CAD modeling?
- Anyone interested in contributing or collaborating on a custom kernel down the road?
-> Check out the Github repo for more information
Thanks for reading — and happy modeling!