LuaCAD is a scripting library which uses OpenSCAD as engine to create 2D and 3D objects.
The LuaCAD library creates OpenSCAD code which is then used to create DXF, SVG, or STL files.
- Install OpenSCAD ( macOS, Linux, Windows )
- Install LuaJIT
- Download the project
- Unzip the project
- Change into the new directory:
cd ./LuaCAD-main - Create your
<name>.luamodel file (including a...:export("out.scad")line) - Execute code with:
bin/luacad <name>.lua
- Open the generated
out.scadfile with OpenSCAD
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 = radius }):translate(5, 0, 0) end model = my_cube + my_sphere(2) model:export("simple.scad")
FennelCAD:
(require :luacad) (local my_cube (cube {:size [1 2 3]})) (print "cube type:" (type my_cube)) ;print info (print "cube scad_content:\n" my_cube.scad_content) (fn my_sphere [radius] (: (sphere {:r radius}) :translate [5 0 0])) (local model (+ my_cube (my_sphere 4))) (export "/tmp/simple.scad" model)
In comparison to OpenSCAD, LuaCAD provides several additional functions that make it easier to create complex models:
- 2D Objects
ellipse()regular_polygon()
- 3D Objects
cone()(can use cylinder with different radii)prism()wedge()torus()surface()
- Extrusions
rotate_extrude()with angle parameter
- Mathematical/Programming
- Most math functions (
cross(),norm(), trigonometric functions) - List operations (
len(),each,range())
- Most math functions (
- Special
import_3mf(),rands(),search()scad(string)- Insert verbatim OpenSCAD code
The OpenSCAD language is limited and has several issues:
- Confusing functions vs modules
- Weird variable scoping
- Not a well establised programming language
- Bad editor support
- Limited documentation
- Limited libraries
- Bad error messages
- Bad performance
Therefore, a real programming language should be used and it should ideally be interpreted and have good operator overloading support
- Julia - Too complex
- Python - Too slow and while easy to get started, hard to master
... and the winner is Lua π
- Powerful
- Consistent
- Fast
- Well established
- Easily embeddable and could therefore be directly integrated into OpenSCAD or a new CAD software
- Similar syntax to OpenSCAD language
- Already used in other CAD software like LibreCAD and Autodesk Netfabb
- Full support or Belfry OpenSCAD Library v2
- Support for exporting
.pngfiles - Implement "LuaCAD Studio" GUI desktop app
Other CAD software that support programmatic creation of 3D models:
- BlocksCAD - Blockly-based CAD software
- Flowscad - Rust interface to OpenSCAD in the spirit of SolidPython
- FreeCAD - Python scripting
- HelloTriangle - 3D modeling with Python scripting.
- ImplicitCAD - Haskell-based CAD software
- LibreCAD - Lua scripting
- Liquid CAD - 2D constraint-solving CAD for rapid prototyping
- ManifoldCAD - Online CAD software using JavaScript
- OpenSCAD Rust - Rust implementation of the OpenSCAD virtual machine
- OpenSCAD - OpenSCAD language
- Rust Scad - Library for generating OpenSCAD code using Rust
- scad_tree - Rust solid modeling library that generates OpenSCAD code
- ScalaCad - Constructive Solid Geometry in Scala
- SolidRS - Rust library to generate OpenSCAD models
- https://willpatrick.xyz/technology/2025/04/23/teaching-llms-how-to-solid-model.html
The initial work was done by Michael Lutz at thechillcode/Lua_CAD.
| Platform | Members |
|---|---|
| r/flossCAD | 441 |
| r/SolveSpace | 454 |
| r/LibreCAD | 461 |
| r/openscad | 7 K |
| r/3dprint | 9 K |
| r/AdditiveManufacturing | 13 K |
| r/KiCad | 13 K |
| r/Lua | 24 K |
| r/FreeCAD | 32 K |
| r/3dprinter | 38 K |
| r/AutoCAD | 43 K |
| r/Creality | 46 K |
| r/cad | 59 K |
| r/prusa3d | 84 K |
| r/Fusion360 | 85 K |
| r/lasercutting | 85 K |
| r/SolidWorks | 94 K |
| r/resinprinting | 96 K |
| r/fosscad | 123 K |
| r/MechanicalEngineering | 184 K |
| r/BambuLab | 225 K |
| r/ender3 | 237 K |
| r/functionalprint | 500 K |
| r/engineering | 668 K |
| r/blender | 1.3 M |
| r/3Dmodeling | 1.4 M |
| r/3Dprinting | 3.0 M |
| Hacker News | - |
| Hackaday | - |
- AD4SM
- cadCAD
- ConstructiveGeometry
- [Descartes]
- FinEtoolsVoxelMesher
- MeshIO
- Modia3D
- OpticSim CSG
- [OpticSim]
Antyos/vscode-openscad: An OpenSCAD extension for VS Code https://github.com/Antyos/vscode-openscad