Scriptable CAD with Lua. Write parametric 2D and 3D models in Lua and export them to STL, 3MF, OBJ, PLY, or SCAD.
LuaCAD embeds Lua 5.4 in a Rust engine that evaluates CSG operations directly (via csgrs) or generates OpenSCAD code for external rendering.
Requires Rust.
git clone https://github.com/ad-si/LuaCAD.git
cd LuaCAD
make installThis installs two binaries:
luacad-- CLI for running and converting LuaCAD scriptsluacad-studio-- GUI desktop app with live 3D preview
luacad convert model.lua output.stl # Convert to STL
luacad convert model.lua output.3mf # Convert to 3MF
luacad convert model.lua output.scad # Export as OpenSCAD
luacad watch model.lua output.stl # Rebuild on file changes
luacad convert model.lua out.stl --via-openscad # Use OpenSCAD backend
luacad run model.lua # Execute (side-effects only)luacad-studioDesktop app with a code editor and 3D viewport. Edit Lua code on the right, see the model update on the left.
my_cube = cube { size = { 1, 2, 3 } }
function my_sphere(radius)
return sphere({ r = radius }):translate(5, 0, 0)
end
model = my_cube + my_sphere(2)
render(model)Equivalent OpenSCAD:
module my_cube() {
cube(size=[1,2,3]);
}
module my_sphere(radius) {
translate([5,0,0]) sphere(r = radius);
}
union() {
my_cube();
my_sphere(2);
}More examples in the examples/ directory.
Check out the website to see all supported features!
The OpenSCAD language is limited and has several issues:
- Confusing functions vs modules
- Weird variable scoping
- Not a well establised programming language
- Bad editor support
- Limited documentation
- Limited libraries
- Bad error messages
- Bad performance
Therefore, a real programming language should be used and it should ideally be interpreted and have good operator overloading support
- Julia - Too complex
- Python - Too slow and while easy to get started, hard to master
Lua is a better fit:
- Well-established, embeddable language
- Operator overloading for natural CSG syntax (
a + b,a - b) - Consistent semantics and good performance
- Similar syntax to OpenSCAD's language
- Already used in other CAD software (LibreCAD, Autodesk Netfabb)
- Full support for Belfry OpenSCAD Library v2
- Support for exporting
.pngfiles
Other CAD software with programmatic model creation:
- BlocksCAD - Blockly-based CAD
- Flowscad - Rust interface to OpenSCAD
- FreeCAD - Python scripting
- HelloTriangle - 3D modeling with Python
- ImplicitCAD - Haskell-based CAD
- LibreCAD - Lua scripting
- Liquid CAD - 2D constraint-solving CAD
- ManifoldCAD - JavaScript-based online CAD
- OpenSCAD Rust - Rust OpenSCAD VM
- OpenSCAD - OpenSCAD language
- Rust Scad - Generate OpenSCAD from Rust
- scad_tree - Rust solid modeling via OpenSCAD
- ScalaCad - CSG in Scala
- SolidRS - Rust OpenSCAD model generation
The initial Lua implementation was done by Michael Lutz at thechillcode/Lua_CAD. The project was later rewritten in Rust.

