Top
Best
New

Posted by c0nsumer 12/20/2025

OpenSCAD is kinda neat(nuxx.net)
327 points | 253 commentspage 3
nayuki 12/22/2025|
> One part that confused me is how I needed to use let() to define startColumn and startRow inside the loop. I don’t understand this…

That's because you wrote a for-loop without braces, so it can only contain a single statement, and that single statement is your let().

Here is an equivalent way to write that section of code (and I did test it):

    for (r = [ 1 : numRows ]) {
        startColumn = ((c * thicknessWall) + ((c - 1) * batteryType));
        startRow = ((r * thicknessWall) + ((r - 1) * batteryType));
        translate([startColumn, startRow, thicknessWall])
            cube([batteryType, batteryType, heightCompartment + 1]);
    }
Side note, related to declaring variables but not an issue that you encountered: OpenSCAD does not allow setting the value of a variable more than once. So this code is illegal:

    x = 1;
    echo(x);
    x = 2;
    echo(x);
Second note is that whenever you introduce a construct such as {union(), difference(), if(), for()}, variables declared within the braces are scoped, so they don't exist between iterations or after the scope ends.

    if (true) { y = -1; }
    echo(y);  // Illegal
However, just introducing braces without a construct does not restrict the variable to the scope:

    { z = 5; }
    echo(z);  // Legal
lorenzohess 12/20/2025||
That let() {} expression seems pretty similar to the LISP let()() form: https://lisp-lang.org/learn/variables
bradfitz 12/20/2025||
I find myself using OpenSCAD regularly to 3D print little things for the house. (Most recently: hooks to attach Christmas lights to our roof deck's glass walls)

And when something gets too trick, ChatGPT is amazing at writing in it. Often it nails the whole design in the first try, like https://bsky.app/profile/bradfitz.com/post/3maelwomyw22n to mask off certain Raspberry Pi pins to make reassembly of projects easier later.

thdrtol 12/21/2025||
Tip (a lot of people don't know this): you can set the resolution by setting the $fn variable. This can be useful when you want to export smooth objects.

  $fn = $preview ? 32 : 64;
voxleone 12/21/2025|
Just a minor aside: When exporting geometry for FEM, you generally should not make $fn very high (values around 32–64 are usually fine). High $fn improves visual smoothness, but it often hurts FEM meshing and solver performance without improving accuracy, since FEM accuracy is governed by the solver’s mesh rather than the CAD tessellation.
arjie 12/20/2025||
Oh I had no idea that OpenSCAD was a programmatic toolkit. I recently bought a 3D printer and I don't model so much as describe to Claude Code how to write a Python script that will generate the required STL that I then rescale or whatever in Bambu Studio. LLMs are great at code-oriented stuff so I've stayed away from traditional modeling tools because I assumed you'd have to point and click and so on and I don't really want to learn the ins and outs of their interface. I just need the right mesh made.

The chatbots kept recommending I try using OpenSCAD but I resisted without even giving it a look. The results I had with just the Python script are quite adequate for the tasks I had. You can just ask the LLM to add a fillet to a vertical pin on a plane or to chamfer some edge and it is pretty good at doing it.

https://wiki.roshangeorge.dev/w/Blog/2025-12-01/Grounding_Yo... if you want to roughly see the workflow.

I'm going to try using OpenSCAD for things in the future. Does anyone else use exclusively an LLM with OpenSCAD (I used Claude Code and Codex) and if you do what did you do to make it more effective? The Python script wouldn't always generate printable meshes so I had to give it a check script to operate on.

ThrowawayTestr 12/20/2025|
Fusion 360 is free for hobbyists and it's not too hard to learn for basic stuff
avmich 12/21/2025|||
Is it online only? I in general prefer locally installed software, without Internet requirements.
fainpul 12/21/2025||
The software is installed locally (runs on macOS and Windows), but your files are stored on Autodesk's servers. You have to sign in to use it. Program startup takes ages. But the features are great.

If you don't need fancy features, have a look at FreeCAD as well.

arjie 12/20/2025|||
Maybe I should suck it up and just give it a crack. Thank you for the recommendation.
gmiller123456 12/21/2025||
I really wish OpenSCAD had objects, so you could use something like box1.width rather than having to declare variables for such things.

I tried using Build123d, a Python library that lets you use all of the features of Python. And it's supposed to allow specifically things like box1.width, but it's always 0. Lots of other issues/bugs too, and severely lacking in ddocumentation.Maybe it'll get there some day.

haberman 12/20/2025||
A long time ago I read that CadQuery has a fundamentally more powerful geometry kernel than OpenSCAD, so I dropped any attempt to try OpenSCAD.

Years later, I never actually got the hang of CadQuery, and I'm wondering if it was a mistake to write off OpenSCAD.

I am pretty new to CAD, so I don't actually know when I would run into OpenSCAD's limitations.

WillAdams 12/20/2025|
The notable limitations for OpenSCAD are:

- functional programming model --- some folks find not having traditionally mutable variables limiting

- output is as an STL, or DXF using polylines

- native objects are spheres, cylinders, cubes, with functions for hull and Minkowski, so filleting and other traditional CAD operations can be difficult

exasperaited 12/20/2025||
Neat-ish.

I don't really see why that code is better, more logical, more readable or more robust than the equivalent quite trivial parametrics in more or less any GUI CAD program, and I think the geek discourse is really harmed by people who don't understand the value of the things that OpenSCAD can't ever offer.

avmich 12/21/2025|
I wonder what kind of things OpenSCAD can't ever offer... It's pretty automatable.
exasperaited 12/21/2025|||
The main thing it cannot ever offer is the ability to further process its own generated geometry. It has no concept of edges, vertices or faces in 3D so you cannot do operations on them, which means no generalised operations like fillets or chamfers, only specific implementations for specific shapes.

This difference is profound, is the point I am getting at.

It also lacks any concept of constraints or constraint solving in 2D sketches, which makes some quite simple shapes extremely difficult to make without advanced maths.

So in both cases you never get away from the maths, and the maths complexity increases as your design complexity increases. You can see this reflected in the complexity of any large OpenSCAD codebase and in the number of functions in any large utility library.

CAD software should aid design. That’s its entire purpose. OpenSCAD just lets you plot 3D shapes and do some very limited operations to combine them.

unbelievably 12/21/2025|||
[dead]
yehoshuapw 12/20/2025||
worth also looking at cadquery, build123d and similar

https://github.com/gumyr/build123d

Robdel12 12/20/2025|
OpenSCAD has become my go to with my 3-D printer for dumb little things. And the best part is LLMs are getting decent / pretty good with it!

My favorite thing I’ve printed is a little downsize coupler for the cool shirt system I built for my spec miata. It’s realllly silly & small thing, but it saved me!

More comments...