LuaCAD

LuaCAD is a scripting library which uses OpenSCAD's engine to create 2D and 3D objects with the power and flexibility of Lua.

The LuaCAD library creates OpenSCAD code, which is then used to create DXF, SVG, or STL files.

Why Lua?

Example

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);
}

LuaCAD:

require("luacad")

my_cube = cube { size = { 1, 2, 3 } }

function my_sphere(radius)
  return sphere({ r = 2 }):translate(5, 0, 0)
end

model = my_cube + my_sphere(2)

model:export("simple.scad")

Getting Started

  1. Install OpenSCAD if not already installed
  2. Download the project
  3. Unzip the project
  4. Create your <name>.lua model file (including a …:export("out.scad") line)
  5. Execute code with: bin/luacad <name>.lua
  6. Open the generated out.scad file with OpenSCAD

Supported Export Formats