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.
Why Lua?
- Similar syntax as the OpenSCAD language, but better:
- More powerful
- More consistent
- Faster
- Easily embeddable
- Operator overloading for natural CSG syntax
(
a + b,a - b,a * b) - Already used in other CAD software like LibreCAD and Autodesk Netfabb
Example
LuaCAD:
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);
}
Getting Started
Requires Rust.
git clone https://github.com/ad-si/LuaCAD.git
cd LuaCAD
make install
This installs two binaries:
luacad— CLI for running and converting LuaCAD scriptsluacad-studio— GUI desktop app with live 3D preview
CLI Usage
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)