Show HN: LuaCAD – Parametric CAD Scripted in Lua

Aug 14, 2026 11:43 PM - 2 hours ago 1

Scriptable CAD pinch Lua. Write parametric 2D and 3D models successful Lua and export them to 3MF, STL, OBJ, PLY, OFF, AMF, aliases SCAD, aliases render them consecutive to a PNG.

LuaCAD embeds Lua 5.4 successful a Rust engine that evaluates CSG operations directly (via Manifold) aliases generates OpenSCAD codification for outer rendering.

LuaCAD Studio previewing the MuSHR racecar model, a 43-part assembly
          of 490,802 triangles, beside the Lua book that builds it

Why Lua?

  • Similar syntax arsenic the OpenSCAD language, but better:
    • More powerful
    • More consistent
    • Faster
    • Easily embeddable
  • Operator overloading for earthy CSG syntax (a + b, a - b, a * b)
  • Already utilized successful different CAD package 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

cargo instal luacad # CLI for moving and converting LuaCAD scripts cargo instal luacad-studio # GUI desktop app pinch unrecorded 3D preview

Or from source, which requires Rust:

git clone https://github.com/ad-si/LuaCAD.git cd LuaCAD make install

Both crates vendor their C/C++ dependencies, truthful nary strategy libraries need to beryllium installed — but a C++ compiler and CMake must beryllium disposable to build them. luacad builds Manifold and Clipper2; luacad-studio additionally builds OpenCSG, which needs OpenGL improvement headers (on Debian/Ubuntu: libgl1-mesa-dev, libx11-dev, libxcb1-dev, libxkbcommon-dev, libxrandr-dev, libwayland-dev).

CLI Usage

luacad person model.lua output.3mf # Convert to 3MF luacad person model.lua output.stl # Convert to STL luacad person model.lua output.scad # Export arsenic OpenSCAD luacad watch model.lua output.3mf # Rebuild connected record changes luacad render model.lua preview.png # Render to a PNG image luacad info model.lua # Print triangle counts and bounding box luacad lint model.lua # Lint pinch selene (also takes directories) luacad tally model.lua # Execute (side-effects only)

convert and watch infer the format from the output extension; --format <fmt> overrides it, and --via-openscad hands the export to an installed OpenSCAD binary alternatively of building the mesh pinch Manifold.

BOSL2

LuaCAD has afloat support for the Belfry OpenSCAD Library v2, reimplemented successful LuaCAD itself, truthful it renders, previews and exports to a mesh without OpenSCAD aliases BOSL2 installed:

bosl.cuboid { {40, 40, 40}, rounding = 2 } bosl.regular_prism { 5, r = 10, h = 25 } bosl.spur_gear { circ_pitch = 5, teeth = 20, thickness = 5 }

Exporting to .scad still writes the BOSL2 telephone itself, which keeps the exported record arsenic short arsenic the book that produced it.

Text and Imports

text() outlines a strategy font into a sketch and text3d() extrudes it successful 1 step, truthful matter becomes real geometry alternatively than SCAD output:

render(text("LuaCAD", { size = 12, halign = "center" }):linear_extrude(2))

import() sounds each mesh format LuaCAD writes and returns a coagulated you tin toggle shape and harvester for illustration immoderate primitive; SVG and DXF return a 2D sketch instead, fresh to extrude.

Supported Export Formats

  • SCAD - OpenSCAD format
  • 3MF - 3D Manufacturing Format
  • STL - Standard Triangle Language for 3D printing
  • OBJ - Wavefront 3D entity format
  • PLY - Polygon File Format
  • OFF - Object File Format
  • AMF - Additive Manufacturing File Format

Every worth your book returns becomes its ain 3MF object, truthful slicers load them arsenic individually movable parts. Label them with :name(…) to power really they look successful the entity list. The different formats cannot definitive abstracted objects, truthful they flatten everything into a azygous mesh.

More