Hacker News new | ask | show | jobs
by cjtrowbridge 28 days ago
This has been easy with OpenSCAD for a long time. I have made lots of cool, complex models this way. I built a repo of the prompts I use to show the llm how to do this and it includes many of the models I've created this way...

https://github.com/cjtrowbridge/vibe-modeling

4 comments

OpenSCAD has almost zero crossover with B-rep modelling ('true' CAD, what this apparently is), though.
This isn't B-rep based modelling. Far from it. It builds up the feature tree and then uses geometry kernel to generate B-rep based representation. The final generator output script could probably be adjusted to generate openscad. It only supports 2d drawings containing lines, arcs and circles and extrude operation for making them 3d. Operations like fillets and chamfers which depend on intermediate B-rep model state are not supported.

I would even argue that for basic modelling majority of tools/features in CAD operate at the abstraction closer to CSG for describing what and B-rep is only treated as how. Just like good chunk of code based CAD use combination of CSG for what and triangle mesh based geometry engine for how. That's assuming you consider standard 2d->3d operations (extrude, revolve, sweep along arbitrary 2d profile) as valid primitives for CSG.

User comes into direct contact of B-rep in very specific situations: 1 doing operations like fillets/chamfers/draft/thickness based on intermediate geometry, 2 attaching sketches or other features to generated geometry or using generated edges (instead of new sketches) for guiding operations like complex sweeps, 3 surface based modelling workflows where you build up the the solid from individual faces typically including complex curved surfaces.

In case of 1 and 2 the the dependency on b-rep based representation is only marginal, in theory you could select edges in triangle mesh based underlying representation but the final result but quality of result wouldn't be as nice and TNP issues for parametric model editing would likely be even bigger than it is for existing CAD. That's not really CSG territory anymore but isn't exclusive to B-rep either, and involves a bunch of work that's outside the scope of B-rep. In non parametric mesh modellers with more destructive editing workflows like blender chamfers and fillets work fine. And if anything for reliable parametric models you often want to limit dependencies on intermediate geometry as that depends on CAD keeping track of where each edge/face originated from outside the b-rep and increases the chance of TNP issues.

3 is critical for industrial design containing large amount of complex curved surfaces like cars and other consumer products, but there are also many more technical parts where it can be completely ignored. Cad tutorials for beginner tutorials almost completely ignore this category of cad modelling. The part about not being exclusive to b-rep also applies for surface modelling part.

how hard it is ? with AI prevalent, how long ? any pointers to start from ?
If you want something based on B-Rep, look at projects that use opencascade under the hood, as that is one of the only B-Rep CAD kernels available which is free and open source. Some examples would be CADQuery, CascadeStudio, or RepliCAD.
OpenSCAD uses CSG which is generally better. Easy to convert CSG to BREP. Cant generally do the opposite
It's easy to convert because CSG is a small subset of what BREP can do.

It's analogous to "all squares are rectangles, but not all rectangles are squares" (squares=CSG, rectangles=BREP)

CSG by itself isn't suitable for most CAD use-cases.

How can I convert openSCAD models to true STEP files? As in no meshes. I Literally have wanted that for years.
You need to use https://github.com/smurfix/buildscad which can convert OpenSCAD to Build123d, then you can export a STEP file. It has a few limitations, but for simple OpenSCAD files it can generate an equivalent representation in OpenCASCADE.
Yeah, that fails for even moderately complex models...
Same. Working with an LLM and OpenSCAD has been totally painless.
I’ve been using cadquery and build123 with Claude code and I find it incredibly painful.

What is your workflow for llm integration to openscad?

I just ask it for what I’m looking for (doing very simple “spare part” level at home 3d printing, nothing fancy or elaborate) and it gives me a starting point. Then I sometimes just edit the scad code by hand, and some times I ask the AI to revise, sometimes a mix (many iterations).

For very simple geometries it works great, but it very quickly becomes apparent that there’s a bit of a disconnect between “LLM views image” and “LLM emits scad that looks like that image” when it comes to anything non-trivial.

Still gives me a starting point I can mess with, which is great since I have zero CAD training or experience.

(I’m not the commenter you replied to)

Tbh that sounds harder than just learning CAD, which is really not that difficult if you use a proper parametric editor - I would recommend SOLIDWORKS first. It's got the easiest UX so is ideal for learning. They actually have a vaguely reasonably priced subscription now, but IMO it's still way too much for occasional hobby use so I'd recommend just pirating it (which is easy).

Once you have learnt a bit then the only FOSS options that are worth a damn are a) SolveSpace which is quite good and light, has a slightly quirky UI (but not in a bad way) but unfortunately has some critical missing features at the moment - notably bevels/chamfers. Although I did see someone made a sloppy PR to add them so we'll see where that goes.

Or b) FreeCAD which is actually good now and fairly close to SOLIDWORKS (at least for the basic stuff you're likely to use) and has a reasonably good UX. Some rough edges still but overall it's very usable. Good enough that I reach for it instead of pirating SOLIDWORKS these days.

The basic workflow is pretty simple:

1. Make some planes, referenced from existing geometry. 2. Make sketches on the planes. 3. Extrude/revolve them (either adding or subtracting from the existing geometry). 4. Repeat until you have the right shape. 5. Add a load of chamfers to make it pretty.

So, steps 1-5 can be done by clicking (tools you recommend), or writing lines of script (OpenSCAD). Once you grok those steps by just doing it yourself, you quickly get to a point where an LLM is quicker at editing the text file that represents the steps to generate the model. Things like "Make the extruded face I labelled blahblah do xyz", and it's quite good. Even better: "Parameterize curve abc and generate this spread" or something. You get it.

For LLM-assisted bespoke model generation it's still fine if you specify a process to follow, and can "speak the language" (knowing 1-5).

This is no different than purevibe vs LLM-assistance, IMHO. What TFA refers to is a more end-to-end, no iterative process, with no single touchpoint script like OpenSCAD offers, so it's very much _not_ a collaboration and requires no knowledge of how CAD models are made.

But this thread is moreso about iterating on an OpenSCAD specification using LLMs.

From my experience people who heavily rely on LLMs are allergic to learning anything new (with the exception of learning new and improved ways to generate slop). They just 'want to get stuff done', even if it means staying in a local maximum forever.
Tell it to use the existing libraries. https://openscad.org/libraries.html, in particular BOSL2

I've one shotted a light saber hilt with threaded parts and it worked flawlessly.

Not OP but I just ask Claude Code to make me an openscad file. If I need changes I ask for them in plain english. If you are specific, it's not the quickest loop but it works. I usually ask it to parameterize the model enough so that I can quickly print small prototypes in my 3d printer. Once I am happy with the mini version I print the full-size model.
check this out: https://modelrift.com/blog/openscad-llm-benchmark LLMs are getting pretty good at OpenSCAD, especially if they work in agentic mode and can inspect intermediate results.
I'm sorry, but which ones of these are complex? I'm looking through some [1] [2] [3] of the output PNGs and they look trivial. Like, my first 3d model in Blender trivial.

In comparison, here's one of my recent designs: what I would still call a very simple case [4]. And it's not like I'm a trained mechanical engineer working commercially, this is stuff I design in my spare time as a programmer.

[1] - https://github.com/cjtrowbridge/vibe-modeling/blob/main/outp...

[2] - https://github.com/cjtrowbridge/vibe-modeling/blob/main/outp...

[3] - https://github.com/cjtrowbridge/vibe-modeling/blob/main/outp...

[4] - https://object.ceph-eu.hswaw.net/q3k-personal/fe3e54e6df604a...

What is the inference overhead on this