logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·31.10.26
← Back to news

Show HN: LuaCAD – Parametric CAD Scripted in Lua

Original article
luacad.ad-si.com|15 points|3 comments|by adius|Aug 14, 2026

LuaCAD: Parametric CAD Scripted in Lua

Welcome to LuaCAD, a powerful tool for creating parametric 2D and 3D models using the Lua programming language. Whether you need to export to standard 3D formats or render a quick preview, LuaCAD provides a flexible, scriptable environment for geometric design.

🛠️ Core Architecture

LuaCAD integrates Lua 5.4 within a high-performance Rust engine. It processes Constructive Solid Geometry (CSG) operations in two ways: directly via the Manifold library or by generating code for OpenSCAD.

🚀 Why LuaCAD?

While it shares a similar philosophy with OpenSCAD, LuaCAD aims to be just a clone a significant evolution.

"LuaCAD offers a more consistent, faster, and more powerful experience. Because it is easily embeddable and supports operator overloading, the syntax for CSG is far more natural."

Natural Syntax Comparison

In LuaCAD, you can use standard mathematical operators for CSG operations, such as A∪BA \cup BA∪B (Union) represented as a + b.

LuaCAD Implementation:

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)

The OpenSCAD Equivalent:

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

📦 Installation Guide

To get started, ensure you have a C++ compiler and CMake installed.

  • Install the CLI: cargo install luacad
  • Install the GUI (Studio): cargo install luacad-studio (Includes live 3D preview)

Alternatively, build from the source:

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

Note on Dependencies: While C/C++ dependencies are vendored, luacad-studio requires OpenGL development headers. On Debian/Ubuntu systems, install: libgl1-mesa-dev, libx11-dev, libxcb1-dev, libxkbcommon-dev, libxrandr-dev, and libwayland-dev.


💻 Command Line Interface (CLI)

The luacad CLI is versatile. Most commands infer the file format from the output extension, though you can override this with --format fmt. To use an external OpenSCAD binary instead of Manifold, use --via-openscad.

CommandPurposeExample
convertTransform script to mesh/SCADluacad convert model.lua output.stl
watchAuto-rebuild on file saveluacad watch model.lua output.3mf
renderCreate a PNG imageluacad render model.lua preview.png
infoShow bounding box & triangle countluacad info model.lua
lintStatic analysis via seleneluacad lint model.lua
runExecute script for side-effectsluacad run model.lua

🌟 Advanced Features

BOSL2 Integration

LuaCAD includes a full Lua reimplementation of the Belfry OpenSCAD Library v2. You can create complex shapes without needing OpenSCAD 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 }

Note: Exporting to .scad preserves the BOSL2 calls, keeping the output concise.

Text and External Imports

  • Text: Use text() to create a font outline (sketch) or text3d() for immediate extrusion.
    • Example: render(text("LuaCAD", { size = 12, halign = "center" }):linear_extrude(2))
  • Imports: The import() function supports all writable mesh formats. SVG and DXF files are imported as 2D sketches ready for extrusion.

📤 Export Formats

Export Formats

FormatNameDescription
.scadOpenSCADNative OpenSCAD script
.3mf3D Manufacturing FormatSupports multiple objects via :name(...)
.stlStandard Triangle LanguageStandard for 3D printing (flattened)
.objWavefrontGeneral 3D object format (flattened)
.plyPolygon File FormatPoint cloud/mesh format (flattened)
.offObject File FormatGeometric representation (flattened)
.amfAdditive Manufacturing FormatXML-based 3D format (flattened)

Pro Tip: When exporting to .3mf, every value returned by your script is treated as a distinct object, allowing slicers to move parts individually. All other formats merge everything into a single mesh.