[HN Gopher] Parametric CAD in Rust
___________________________________________________________________
Parametric CAD in Rust
Author : ecto
Score : 130 points
Date : 2026-01-27 20:36 UTC (10 hours ago)
(HTM) web link (campedersen.com)
(TXT) w3m dump (campedersen.com)
| nynx wrote:
| Unfortunately, using a geometry kernel [1] that operates on
| triangle meshes means this is a no-go for serious CAD usage.
|
| [1]: https://github.com/elalish/manifold
| bigfishrunning wrote:
| My whole CAD experience is with OpenSCAD, which apparently uses
| the same kernel; Honest question -- what is the alternative? I
| would assume the vast majority of 3D model processing relies on
| triangle meshes...
| autumn-antlers wrote:
| libfive
| nynx wrote:
| Breps. Nearly all commercial cad packages operate on boundary
| representations of objects.
| bob1029 wrote:
| I would start with CSG if you are new to these ideas:
|
| https://en.wikipedia.org/wiki/Constructive_solid_geometry
| pca006132 wrote:
| Mesh is also a boundary representation. I think you meam
| NURBS.
| nicr_22 wrote:
| OpenCASCADE?
|
| https://dev.opencascade.org/
| zokier wrote:
| Notably wrapped by build123d into cad as a code package
| Brian_K_White wrote:
| Meshes are an output, not a source, and not a good internal
| representation.
|
| Meshes are only a lossy approximation of the actual geometry,
| and the errors accumulate as features reference off of
| earlier features.
|
| A simple example is a line tangent to an arc. The line will
| only be the correct distance from the center of the arc at
| one point (one angle) per segment.
|
| In openscad you don't notice the problem because since it's
| code and you have variables and programming ways of
| expressing relationships, you would usually not try to derive
| one thing from another by geometry, instead both things would
| reference a common ancestor variable. But that's a technical
| implimentation detail that works around the problem by just
| not doing a thing that doesn't work. The problem is still
| there that a valid geometry constraint would produce invalid
| results.
| xixixao wrote:
| I've built something very similar (also based on triangle
| meshes, but in TS), and while it wouldn't work for say 3D
| printing, my target is game object modeling. I guess people
| have specific use cases in mind when referring to "CAD".
| nynx wrote:
| In my mind, cad that you're not going to manufacture is
| "modeling". Not sure if that's a common verbal distinction.
| ezst wrote:
| Not sure either but sharing the sentiment.
| bigiain wrote:
| An example of common terms that disagrees with that
| somewhat, is "CAD/CAM" where the design component is
| clearly distinct from the manufacturing component.
|
| I do agree that historically, software aimed at building 3d
| models for games/animations and other digital use was
| usually called modeling and not cad. I'm thinking of
| software like 3D Studio Max back in the 90s here.
|
| https://en.wikipedia.org/wiki/CAD/CAM
|
| I notice though that the Wikipedia article for CAD says:
| "This software is used to increase the productivity of the
| designer, improve the quality of design, improve
| communications through documentation, and to create a
| database for manufacturing."
|
| https://en.wikipedia.org/wiki/Computer-aided_design
| dgently7 wrote:
| my personal distinction I use is about measurements.
| while you may model to a specific scale for use in 3d gfx
| (game by engine/animation/vfx) you cross over from
| "modeling" to "cad" as soon as you are creating geometry
| with specific real world measurements. (probably for
| manufacturing or engineering reasons bc thats when it
| matters most)
|
| like I can model a table that is the right size and looks
| like it will not tip over for my game, but I am going to
| cad that table to run a stress sim and make the plans for
| building it for real.
|
| though id still call the action of doing the building in
| the cad software "modeling"... so idk.. language is
| weird.
|
| so software that lets you work accurately with
| measurements and real units == cad. (fusion360) software
| that just makes geometry == modeling. (blender)
|
| but if you wanna go get real confused look at
| "plasticity" an app targeted at "modeling" but uses a cad
| engine and sells itself as "cad for artists" it has real
| scale measurements and everything too.
| maartenh wrote:
| Curious to how well LLM's work in this context! (mentioned as one
| of the reasons to embed CAD in Rust)
|
| I only know of another text -> STL AI model, I'm quite a bit more
| excited about this idea.
|
| Does someone have experience with this?
| storystarling wrote:
| I've found LLMs perform surprisingly well here if you target
| CSG or OpenSCAD. It seems to frame the 3D modeling challenge as
| a logic and syntax problem rather than a spatial one, which
| plays to the model's strengths. You avoid the spatial
| hallucinations common in image generation because it's
| effectively just writing code.
| d_silin wrote:
| Interesting, because I am trying to learn OpenSCAD for some
| simple modeling.
| the__alchemist wrote:
| Note: This is probably a dead-end; it is not on the same level
| as SolidWorks, Fusion etc.
| ecto wrote:
| How could I make it better?
| the__alchemist wrote:
| Sorry about the confusion - I'm referring to OpenSCAD; not
| your project.
| avmich wrote:
| You're probably right, OpenSCAD seems to be limited both in
| speed and in exactness of the surfaces.
|
| However purely programmatic interface allows doing surprising
| things which might be hard to achieve with a mouse.
| whilenot-dev wrote:
| I wouldn't call a FOSS project that you compare to some 2,620
| USD/year software a dead-end. It's good enough for simple
| modeling, especially when it comes to scripting, and has been
| for 10 years already.
| 8note wrote:
| definitely learn solidworks or something in that vein first
|
| that, and as a prior skill, learn to draw by hand on paper
| orthogonal and isometric views of 3d objects.
|
| cad is another theory building excercise, but instead of being
| about processes, its about objects. you want to start from a
| strong manual/first principles base
| d_silin wrote:
| I liked CATIA, but can't afford it at the moment.
| nomel wrote:
| If you're more interested int the result than the process,
| Onshape or Fusion are _great_ , free (with use restrictions)
| parametric CAD. And both support scripting, to some extent.
|
| Both have really great documentation/examples.
| hambes wrote:
| I've been doing a similar thing using GhostSCAD[1], which is a
| relatively thin wrapper around OpenSCAD in Go. Not as typesafe,
| but my language of choice.
|
| [1]: https://github.com/ljanyst/ghostscad
| oussama-gmd wrote:
| Amazing work! This is what I was looking for, I thought of this
| few months ago and didn't have the time to create it myself.
| Thanks will explore it and give my feedback!
| kibwen wrote:
| Note that there's an existing CAD-in-Rust project, Fornjot, which
| has been quietly developing since 2020: https://www.fornjot.app/
| mountainriver wrote:
| Also Truck https://github.com/ricosjp/truck
| Cargo4286 wrote:
| Neither Fornjot nor Truck are ready for general use as a BREP
| CAD kernel.
| davidmedin wrote:
| This sounds a lot like Fidget (https://github.com/mkeeter/fidget)
| and libfive (https://github.com/libfive/libfive) by the amazing
| Matt Keeter!
| ecto wrote:
| Hadn't ran into these, thanks!
| rnhmjoj wrote:
| I had a lot of fun playing around with antimony (also from
| Keeter) a few years ago, but unfortunately it has been mostly
| abandoned. I heard libfive is supposed to be the next
| generation, but I haven't experimented with it yet.
|
| Do you know how it compares?
| FpUser wrote:
| I am constantly designing parts myself. I just wish that instead
| of having many unfinished, unpolished products we had something
| with the level of Solidworks / Onshape / whatever.
|
| FreeCad is getting somewhere but it is still way behind. The last
| thing I care about is what language was it implemented with.
| kivarada wrote:
| Great work! Please consider adding a RSS/Atom Feed to your site.
| I would like to include it in my Tech Content Platform:
| https://insidestack.it
| ecto wrote:
| Done, thanks for the kind words!
| kivarada wrote:
| Great, I already added you!
| etskinner wrote:
| The opening paragraph is very telling; the author doesn't seem to
| understand typical pro-level parametric CAD programs available on
| the market:
|
| > 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.
|
| This doesn't make sense. When you realize the bolt pattern is 2mm
| off, you just edit that dimension and let the CAD program
| recalculate. You don't need to click around for an hour again.
| That's the beauty of contstraint-based parametric modeling as
| opposed to, say, modeling in Blender.
|
| The author's program is akin to writing vim to replace Publisher.
| They're solving entirely different problems. Not to mention, this
| code-as-model paradigm already exists: OpenSCAD
| ecto wrote:
| You're correct, I'm completely uneducated! Pull requests
| welcome :)
| IshKebab wrote:
| The pull request is to delete the project and open SOLIDWORKS
| or FreeCAD.
|
| But don't actually delete it. It looks like a nice
| alternative to OpenSCAD. But like OpenSCAD it's really a
| niche thing for designs that are _highly_ parametric like
| fasteners, gears, 3D printed boxes, etc.
|
| Like OpenSCAD using it for normal "irregular" CAD is going to
| be extremely frustrating. Like editing an SVG in notepad
| instead of Inkscape.
|
| I still feel like there's a unexplored space where you
| combine the benefits of both somehow though. Like a code-
| based CAD but it also has a GUI editor that stays in sync and
| avoids the need to type in coordinates by hand. That would be
| extremely difficult though.
| aaronblohowiak wrote:
| >I still feel like there's an unexplored space where you
| combine the benefits of both somehow though. Like a code-
| based CAD but it also has a GUI editor that stays in sync
| and avoids the need to type in coordinates by hand. That
| would be extremely difficult though.
|
| I think you can do this if the data representation of
| operations and values is human readable. The simplest
| implementation would restrict the language/data format to
| operations representable in the gui.
|
| Unlike trying to solve the "visual programming" problems,
| we don't need or desire Turing completeness.
|
| Very interesting indeed!
| NonHyloMorph wrote:
| Are you aware of Rhino 3D with grasshopper?
| amelius wrote:
| > Like editing an SVG in notepad instead of Inkscape.
|
| Speaking of which, I would love to have parametric
| capabilities in Inkscape.
| TheTaytay wrote:
| I recently stumbled across cuttle.xyz, and it's a code-
| based parametric vector editor. I recently did a real
| world art project in it and LOVED it.
| DannyBee wrote:
| This is actually what onshape is, under the covers.
|
| The GUI is really just using their scripting primitives,
| etc. You can access it the same as they can, actually.
| throwup238 wrote:
| Onshape is just a GUI over the Parasolid geometric
| modeling kernel, the same kernel used by Solidworks [1].
| Whatever their scripting primitives are, they're at best
| a thin wrapper over Parasolid (which is true for the
| entire industry - it's all Siemens Parasolid and Dassault
| ACIS).
|
| [1] https://en.wikipedia.org/wiki/Parasolid#Applications
| gwbas1c wrote:
| Read a bit before critisizing:
|
| > One thing I care about that most CAD tools don't: vcad is
| designed to be used by AI coding agents.
| ilogik wrote:
| For that there's openscad
| hnuser123456 wrote:
| I've even already asked an LLM to generate designs in
| openscad, and there's plenty of examples out there.
| Obviously there's a complexity limit, but there's also a
| cheat sheet that makes it pretty easy to discover how to do
| almost anything that's possible within.
| amelius wrote:
| AI coding agents are notoriously bad at anything that
| involves spatial awareness.
| bangaladore wrote:
| > That's the beauty of constraint-based parametric modeling as
| opposed to, say, modeling in Blender.
|
| I was thinking the same thing. This looks more like an API that
| makes 3d modeling look closer to CAD, but without realizing
| that CAD is about constraints, parametrizing, and far more.
| throwup238 wrote:
| _> but without realizing that CAD is about constraints,
| parametrizing, and far more_
|
| Constraints and parametrizing are the trivial parts of CAD,
| something you can now implement in a weekend with Claude
| Code, the MINPACK/SolveSpace test suite, and OpenCascade as
| an oracle. The hard part is a geometric kernel that can
| express boundary representations for complex shapes
| (sketches, chamfers, fillets, etc) and boolean operations
| while somewhat handling the topographical naming problem
| without driving the user insane (which existing kernels are
| still all shit at).
| asdfaslkj353 wrote:
| Absolutely atrocious and piss-poor contrast. Can barely read a
| thing.
| ecto wrote:
| Are you feeling alright?
| asdfaslkj353 wrote:
| Yes, I am alright, the website attempts to support dark-mode
| but does such a poor job of it that renders it completely
| useless.
|
| https://i.ibb.co/VppSx4mc/pisspoor.png
| golem14 wrote:
| I agree the UI on the screenshot is not very accessible.
| I'm also think that language and tone choice matter a lot
| when delivering (even constructive) criticism.
| ecto wrote:
| Thank for the feedback. Have a nice day.
| tuetuopay wrote:
| GP perhaps did not say it in a polite manner, but their
| criticism is valid.
|
| Please have a check on a different monitor and browser than
| you are currently using, as most of the article is
| unreadable. Code blocks are nigh unreadable, and the
| screenshots are washed out as if they were HDR with improper
| tone mapping (I tested both with Firefox on Linux and Safari
| on iOS).
|
| It's a shame, because it made me gloss over the article.
|
| Oh, and the screenshots have the same issue both on the blog
| post and on the main vcad.io website. Funnily enough, code
| snippets on vcad.io have proper readable colors as opposed to
| your blog (they're still too dim to be comfortable though,
| but they're readable).
| gwbas1c wrote:
| What's nice about this is that it allows for programmatic CAD,
| enabling things like web applications that can download an .stl
| file based on user input. I hope I can find a weekend or two to
| play with it.
|
| BTW: I spent a few weekends playing with Microcad
| (https://microcad.xyz/). It was cool, and had a similar rust
| feel. I just, for the life of me, couldn't figure out how to do
| 3d ellipses.
| Cargo4286 wrote:
| Here's an ellipsoid in build123d using geometric transformation
| of a sphere: from build123d import *
| mat = Matrix([[2,0,0,0],[0,1.5,0,0],[0,0,0.5,0]])
| ellipsoid = Sphere(100).transform_geometry(mat)
|
| Also, FYI build123d now runs in the browser thanks to OCP.wasm.
| Example playground here
| https://jojain.github.io/build123d-sandbox/
| asimeqi wrote:
| If you are using build123d, probably the easiest way is to
| sketch an ellipse and revolve it.
| Cargo4286 wrote:
| The definition of an ellipsoid is that it can have three
| independent radii. A revolved ellipse only has two
| independent radii. If only two independent radii are needed
| then yes I agree with you, but I wanted to provide a fully
| qualified answer.
| ge96 wrote:
| SketchUp was my go to for a while but I'm done with parametric
| personally, trying to fix meshes for 3D printing... time I grow
| up and use something like Fusion360 seems like or onshape. Still
| it was good/simple enough for non-round shapes in SketchUp except
| they have some kind of memory leak/bug at least for the 2017
| version. But I guess quit being cheap and buy a modern copy on my
| part.
|
| Edit: oh I guess sketchup is a surface modeler weird thought it
| was parametric this whole time, lol someone else said it's a
| polygon modeler
|
| Yeah I don't know what parametric modeling is apparently, I use a
| mouse/calipers to model stuff not parameters
|
| There is a solid validator plugin you use before you export an
| STL to make sure the mesh is closed/a manifold
| IshKebab wrote:
| SketchUp uses direct modelling, not parametric modelling. I
| think they even got some patents on direct modelling.
| Animats wrote:
| It's using a constructive solid geometry system. You can add
| and subtract volumes. Making a hole is subtracting a volume.
| This has classically been numeric roundoff hell, where points
| that should coincide and surfaces which should touch don't get
| handled properly due to numerical error. _The geometry engine
| is Manifold, which guarantees watertight meshes from boolean
| operations._
|
| Ah. That's what's doing the constructive solid geometry. Here's
| the 2009 PhD thesis behind the object merge and difference
| algorithms inside Manifold. Nice. At last, soundness. This is a
| long-standing problem. And now there's an open source
| implementation. Manifold itself is in C++, not Rust, though.
|
| None of this is parametric. That's a different problem. That's
| where you put in constraints such as A is perpendicular to B, B
| is 100mm from C, etc., and the constraint solver tries to
| satisfy all the constraints. Change a dimension and everything
| adjusts to preserve the constraints. Parametric CAD is all
| about constraint solving and expressing conflicts to the user.
| Autodesk Inventor, Fusion, etc. have good constraint solvers.
|
| [1]
| https://github.com/elalish/manifold/blob/master/docs/RobustB...
| MomsAVoxell wrote:
| Manifold (which is doing the heavy lifting in this) uses
| triangles, which are an approximation.
|
| This is never going to have the accuracy seen in higher-end
| CAD circles, which use b-Reps: highly accurate mathematic
| representation.
|
| Manifold is good for visualization, but to use it as an
| engine for manufacturing .. its limits will be hit.
| hahahahhaah wrote:
| Why not use OpenSCAD?
| amelius wrote:
| Because it is not written in Rust, I suppose.
|
| Anyway, I think using only code for designing 3D objects is a
| poor design choice. You really need something that is between
| pure code and pure GUI.
| WillAdams wrote:
| I would really like to see someone work that up.
|
| I suspect that Moment of Inspiration and Rhinoceros 3D are
| something along those lines, but I'm not aware of an
| opensource tool which hoes that row.
|
| One thing in particular which it would be nice to see would
| be a facility where one could draw a piece of geometry, then
| all the coordinates/values which describe it could be
| displayed in a pane where they could then be named or re-
| arranged, or the values changed, or even the values changed
| into formulae.
| jas8425 wrote:
| Is anyone else put off by the AI-sounding text? Two things that
| give it away for me are the excessive use of punctuation-
| emphasized sentence fragments ex:
|
| > No clicking. No undo. Just recompile.
|
| > That's our mascot. Entirely CSG.
|
| > No garbage collection pauses. No floating point surprises from
| a scripting layer.
|
| And worst of all, the dreaded "and/but honestly":
|
| > But honestly, the main reason is the toolchain.
|
| Am I misreading things?
| ecto wrote:
| Thanks for the feedback
| librasteve wrote:
| I get the sense that this author is looking for a DSL (domain
| specific language) and landed quite close.
| vhantz wrote:
| Yet another rewrite-it-in-rust-just-because project. I'll stick
| with OpenSCAD
| amelius wrote:
| Based on a geometry engine written in C++ ...
|
| https://github.com/elalish/manifold
| jlarocco wrote:
| Not to crap on this project too much, but this, and most of the
| other small CAD projects that get posted here, always have a
| condescending, "Look how easy I've made this" vibe to them, and
| then they're always light years behind modern CAD software.
|
| If you're doing serious CAD work, like designing a whole machine,
| or working with multiple vendors to get parts manufactured, then
| it really is worth paying for a commercial CAD system and
| learning how to use it. All of the commercial CAD systems today
| support parametric modelling where later operations are updated
| automatically when the earlier operations are changed by the
| user.
|
| If you insist on writing code, then even entry level systems like
| SolidWorks have APIs to do everything from creating the part
| geometry, defining geometric tolerances and PMI, running
| simulations, doing different types of analysis, creating
| machine/tooling instructions (G-code, etc.), exporting to various
| formats, and a million other things.
|
| And they have workbenches for manufacturing techniques other than
| 3D printing, like sheet metal, CNC machining, cable routing,
| injection molding, welding, etc. And most of them have libaries
| of standard and off the shelf parts, like screws, bolts, nuts,
| washers, cables and housings, etc. in various standardized sizes
| so you don't have to model those at all.
|
| For testing, on the higher end, the CAD systems integrate with
| metrology hardware and they're able to actually measure the
| manufactured parts and compare against the model to validate that
| they have the correct shape and meet all of the tolerances. Not
| as a virtual unit test running in CI, but by actually measuring
| the physical part.
| kingstnap wrote:
| I had Google Gemini 3 write me a part using human language about
| 3 weeks ago for a 3D printing project.
|
| I specifcally had it spit out a FreeCAD macro, which is basically
| Python that looks like what you've made.
| MITSardine wrote:
| If anyone is interested, you can try EngineeringSketchPad
| (https://acdl.mit.edu/ESP/) which is very similar but much more
| mature. It also supports simple geometric primitives and boolean
| operations via a scripting language, but also more general
| rational curves and surfaces (i.e. BREPs). It has other nice
| features like differentiation, application-specific views (think
| structural vs CFD), and an attention to water-
| tightness/correctness.
| zombot wrote:
| > Types prevent you from passing a radius where a diameter was
| expected. CAD files should be code. Code has tests, reviews,
| diffs, and CI. An STL file has... bytes.
|
| Fucking A Right!
___________________________________________________________________
(page generated 2026-01-28 07:00 UTC)