Show HN: LuaCAD – Parametric CAD Scripted in Lua

Hacker News Top Tools

Summary

LuaCAD is a scriptable CAD tool using Lua for parametric 2D and 3D modeling, built on a Rust engine with support for various export formats and CSG operations.

LuaCAD models solids in Lua rather than the OpenSCAD language, with operator overloading for CSG (`a + b`, `a - b`, `a * b`).<p>It ships with a CLI and a desktop app, including a preview area and a text editor.<p>I&#x27;ve always been a big fan of OpenSCAD, but the SCAD language itself is unfortunately quite cobbled-together and is a very poorly designed programming language.<p>LuaCAD takes all the good parts of OpenSCAD and combines them with one of the best scripting languages. It has now completely replaced OpenSCAD for me, and I think it provides a better experience than OpenSCAD for all use cases. I&#x27;d love to hear any reasons why LuaCAD shouldn&#x27;t fully replace OpenSCAD!<p>It’s fully open source and you can find the repo here: <a href="https:&#x2F;&#x2F;github.com&#x2F;ad-si&#x2F;LuaCAD" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ad-si&#x2F;LuaCAD</a><p>Tech stack:<p>- It&#x27;s implemented in Rust and uses mlua (<a href="https:&#x2F;&#x2F;github.com&#x2F;mlua-rs&#x2F;mlua" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mlua-rs&#x2F;mlua</a>) to execute the Lua code.<p>- Uses OpenCSG (<a href="https:&#x2F;&#x2F;opencsg.org" rel="nofollow">https:&#x2F;&#x2F;opencsg.org</a>) for fast and correct rendering of the 3D models (like OpenSCAD)<p>- Uses Manifold (<a href="https:&#x2F;&#x2F;github.com&#x2F;elalish&#x2F;manifold" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;elalish&#x2F;manifold</a>) to create the manifold triangle meshes<p>- Native support for all BOSL2 functions (i.e. implemented in Rust for better performance)
Original Article
View Cached Full Text

Cached at: 08/14/26, 06:30 PM

# LuaCAD Source: [https://luacad.ad-si.com/](https://luacad.ad-si.com/) Scriptable CAD with Lua\. Write parametric 2D and 3D models in Lua and export them to 3MF, STL, OBJ, PLY, OFF, AMF, or SCAD, or render them straight to a PNG\. LuaCAD embeds Lua 5\.4 in a Rust engine that evaluates CSG operations directly \(via[Manifold](https://github.com/elalish/manifold)\) or generates[OpenSCAD](https://www.openscad.org/)code for external rendering\. ![LuaCAD Studio previewing the MuSHR racecar model, a 43-part assembly of 490,802 triangles, beside the Lua script that builds it](https://luacad.ad-si.com/images/luacad-studio-screenshot.png)## 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](https://github.com/LibreCAD/LibreCAD_3)and[Autodesk Netfabb](https://help.autodesk.com/view/NETF/2025/ENU/?guid=GUID-93C06838-2623-4573-9BFB-B1EF4628AC4A) ## 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 install luacad # CLI for running and converting LuaCAD scripts cargo install luacad-studio # GUI desktop app with live 3D preview ``` Or from source, which requires[Rust](https://www.rust-lang.org/tools/install): ``` git clone https://github.com/ad-si/LuaCAD.git cd LuaCAD make install ``` Both crates vendor their C/C\+\+ dependencies, so no system libraries need to be installed — but a C\+\+ compiler and CMake must be available to build them\.`luacad`builds Manifold and Clipper2;`luacad\-studio`additionally builds[OpenCSG](http://www.opencsg.org/), which needs OpenGL development headers \(on Debian/Ubuntu:`libgl1\-mesa\-dev`,`libx11\-dev`,`libxcb1\-dev`,`libxkbcommon\-dev`,`libxrandr\-dev`,`libwayland\-dev`\)\. ### CLI Usage ``` luacad convert model.lua output.3mf # Convert to 3MF luacad convert model.lua output.stl # Convert to STL luacad convert model.lua output.scad # Export as OpenSCAD luacad watch model.lua output.3mf # Rebuild on file 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 with selene (also takes directories) luacad run 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 instead of building the mesh with Manifold\. ## BOSL2 LuaCAD has full support for the[Belfry OpenSCAD Library v2](https://github.com/BelfrySCAD/BOSL2/wiki), reimplemented in LuaCAD itself, so it renders, previews and exports to a mesh without OpenSCAD or 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 call itself, which keeps the exported file as short as the script that produced it\. ## Text and Imports `text\(\)`outlines a system font into a sketch and`text3d\(\)`extrudes it in one step, so text becomes real geometry rather than SCAD output: ``` render(text("LuaCAD", { size = 12, halign = "center" }):linear_extrude(2)) ``` `import\(\)`reads every mesh format LuaCAD writes and returns a solid you can transform and combine like any primitive; SVG and DXF return a 2D sketch instead, ready to extrude\. ## Supported Export Formats - **[SCAD](https://en.wikipedia.org/wiki/OpenSCAD)**\- OpenSCAD format - **[3MF](https://en.wikipedia.org/wiki/3D_Manufacturing_Format)**\- 3D Manufacturing Format - **[STL](https://en.wikipedia.org/wiki/STL_(file_format))**\- Standard Triangle Language for 3D printing - **[OBJ](https://en.wikipedia.org/wiki/Wavefront_.obj_file)**\- Wavefront 3D object format - **[PLY](https://en.wikipedia.org/wiki/PLY_(file_format))**\- Polygon File Format - **[OFF](https://en.wikipedia.org/wiki/OFF_(file_format))**\- Object File Format - **[AMF](https://en.wikipedia.org/wiki/Additive_manufacturing_file_format)**\- Additive Manufacturing File Format Every value your script returns becomes its own 3MF object, so slicers load them as individually movable parts\. Label them with`:name\(…\)`to control how they appear in the object list\. The other formats cannot express separate objects, so they flatten everything into a single mesh\.

Similar Articles

CADFather: Autonomous CAD Reconstruction through Coordinated Tool Use

Hugging Face Daily Papers

CADFather is an autonomous agentic system that reconstructs editable parametric CAD programs from 3D meshes by coordinating a vision-language assistant with complementary learned, algorithmic, and optimization tools, evaluated on benchmarks like DeepCAD, Fusion360, and CADENA-Bench without additional training.

OpenSCAD the Programmers Solid 3D CAD Modeller

Hacker News Top

OpenSCAD is a free, open-source, programmer-oriented software for creating solid 3D CAD objects, available on Linux, Windows, and macOS, with tutorials, libraries, and community support on IRC and Mastodon.

StepCAD: Mesh-to-CAD Code Generation via LLM Policy and Geometry-Guided Search

Hugging Face Daily Papers

StepCAD 提出了一种将状态条件化 CAD 策略与 IoU 引导树搜索相结合的生成式优化方法,从 3D 网格重建可执行 CAD 程序,并发布了包含 150 万个程序的 ARCADE-1.5M 大规模数据集,在多个基准上实现了最先进的几何重建精度。