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")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()
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
- FreeCAD - 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
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 | - |