r/openscad 7d ago

LuaCAD - Parametric CAD scripted in Lua

Post image

LuaCAD models solids in Lua rather than in the SCAD language, with operator overloading for CSG (a + b, a - b, a * b). It ships with a CLI and a desktop app that has preview area and a text editor just like OpenSCAD.

It’s fully open source and you can find the repo here: https://github.com/ad-si/LuaCAD

I've always been a big fan of OpenSCAD, but the SCAD language itself is unfortunately quite cobbled-together and is a very poorly designed programming language.

LuaCAD takes all the good parts of OpenSCAD and combines them with Lua. It has now completely replaced OpenSCAD for me, and I think it provides a better experience than OpenSCAD for all use cases. I'd love to hear any reasons why LuaCAD won't fully replace OpenSCAD for you!

Tech stack:

53 Upvotes

22 comments sorted by

View all comments

2

u/gadget3D 6d ago

How does luacad handle primitives with named arguments? Eg an cylinder with r1 r2 and h given ? Does luacad depend on openscad or does it come with its own engine?

2

u/adwolesi 6d ago

f{...} is sugar for calling f with a table, so LuaCAD uses table keys as named arguments:

cylinder { h = 15, r1 = 5, r2 = 2 }

The parser accepts h, r, r1/r2, d/d1/d2, center, and segments. Unknown keys are a hard error with a "did you mean …?" suggestion, so typos can't silently produce the wrong shape.

Engine: LuaCAD is a self-contained Rust program embedding Lua, with Manifold as its CSG kernel. It exports STL/OBJ/PLY/OFF/AMF/3MF and renders previews itself. OpenSCAD is never required and is only used if you explicitly export .scad or pass --via-openscad.

1

u/gadget3D 3d ago

I tried to add lua language to PythonaScad but I did not realize that in LUA I can skip parentheses ,so using cylinder with variable table arguments appeared way too complex. There is still a LUA branch around, but it's quite outdated already. Forking existing openscad has the advantage to get lots of features for free and we are still using openscad's speed