← Back to context

Comment by bschwindHN

3 days ago

Nice! I love code-based CAD. Eventually I want to build a tool which uses a hybrid approach: a GUI for things that are hard/tedious to express in code like complicated 2D sketches, with code as the "persistence" layer so at the end you still just have code to maintain, no binary files or piles of XML.

One of the hard parts though will be synchronizing changes between UI and code. I suppose it could start as a unidirectional flow from UI to code... if you were to generate a sketch with something like a loop, it would be hard to recover that code structure from just a bunch of resulting points and line segments.

But anyway, I'm happy to see more code-based CAD approaches pop up. I think there's still a lot to explore in this space.

For my airplane design, I've used Rhino3D (which is 3d modeling, not CAD), and used their Python-based plug-in API to create a very custom, limited scope parametric CAD on it... using a mix of geometric and aerodynamic parameters, and using vortex lattice methods to bridge between them. So the wing chord (MAC) can be set in centimeters, but the wing span set to achieve a specific modeled climb rate. It's all very ad hoc, but also lovely to develop in. Hit run, in three seconds have a freshly-generated OML, use Rhino's UI to make a few changes, confirm I like them, then move those changes to code and re-run. Hit undo/redo a few times to compare the hand-drawn and generated versions, then move on to the next feature.

  • Do you find you prefer python to grasshopper? I loved how easy it was to connect data sources to geometry, and feedback is instantaneous. never tried the Python plugin.

    • (a) I started this before grasshopper was mature enough to use. (b) I haven't looked too much into grasshopper because of that, but my impression was that the version control story was basically non-existent. As pure text, Python is easier to change review and to version. (c) Having a "real" language to bridge to other languages is fundamental for what I'm doing. For example, the panel code is written in Fortran, and the CFD libraries are written in C++.

  • Why would you say Rhino 3D "isn't CAD"?

    • Well, it's certainly not parametric CAD -- it's a drawing program that happens to be in 3D, with limited (and, I'm very glad to see, growing) ability to use history for some more structured creation. But the biggest limitation is that it's numerics are mediocre, and subtle -- everything is in float space, and it's very easy to get into a space where things just don't make sense, especially far from the origin. In a CAD tool I'd expect to be able to enforce constraints to resolve this ("these two points must match"); I've been able to do that somewhat with my plug-in when the precision is there but the error stack-up has been too high, but there's also cases where the precision just doesn't exist.

      6 replies →

FreeCAD apparently supports OpenSCAD as well as build123d, which looks like a very nice DSL for geometry. Still no 2 way binding tho, unless you count the variable editor in the GUI.

> Nice! I love code-based CAD.

I haven't tried it yet, but I would think that coming up with variable names for all the little parts and distances and whatnot must be a nightmare! :)

And could someone read the code and understand it?

  • Depends on the complexity of the model and how you organize it. If it's broken into functions where one function is one relatively simple part of the model, things work pretty nicely. And names are scoped to the function so you don't have to worry about polluting some global scope.

    But if you're making something very complicated, code-based CAD sort of falls apart, which is why I'd love to see some sort of hybrid approach.

> I love code-based CAD.

So do I. A lot.

But wait until you try to pair it with an Agentic AI, it will simply blow you away.

Until, that is, you realize LLM's have strictly no sense of how 3D geometry works, but still, it's amazing.

  • I too love seeing code-based CAD and the general aspect of using LLM's using code as an expression-intermediary: SQL to data, Swift to CAD, SVG to images of pelicans.

    I have not used Constructive Solid Geometry CAD MCPs myself (but I have used some of the AI model creators). Some of the videos I've seen look very cool.

    But, I wonder how much longer the claim of "LLM's have strictly no sense of how 3D geometry" works will stand.

    Last week I used Claude extensively to design the upgrade to my homemade pontoon boat. In addition to my textual descriptions, I uploaded pictures of hat channel cross-sections with dimensions and screenshots of my CAD drawings. I was asking questions about strength and stability and relationships between parts and evolved the design. It took some sort of world understanding of boats, relationships of parts, types of physical interconnects, materials properties. There's definitely some understanding going on.

    ---

    Actually, show rather than tell. I just took Cadova for a spin, using screenshots of my boat's CAD and the previous conversation. Then I vibe-coded my boat up with Cadova, in an agentic loop with Claude Desktop and VSCode and the Cadova Viewer and screen shots. Pretty wild. Certainly not perfect, and I don't think this is how I would actually go about it, but it was interesting!

    There's nothing proprietary, so I'll made a quick GitHub project [1] since the Claude links don't show files.

    [1] https://github.com/ConAcademy/WeaselToonCadova

    • I've started fresher and am now in an agentic loop in Claude Code, asking it to render the generated 3mf and look at the results and evolve the Swift code to have a model that matches the reference image. Not sure how it will go but it is doing it.... will eventually update the repo.

  • Funny that you say that. Just yesterday I was playing with the thought of using SDFs. I asked ChatGPT how, given a SDF, I could implement erosion followed by dilation (by the same amount), and ChatGPT said that the entire operation is the identity. Here the LLM failed to see that the erosion step could delete parts of the design. Anyway, it was interesting to see an area where LLMs clearly have no idea what they're talking about.

    • I've had very poor results trying to reason about geometry with chatgpt (to the point where it hallucinated that a line can intersect a sphere 3 times...) but it would be interesting to have a feedback loop from code to image. I just found out about build123d as a newer variety of cadquery and looking forward to trying an LLM out with it.