u/pr0m1th3as

I've used OpenSCAD for years and kept hitting the same walls, so I built exact CAD modelling for GNU Octave

I've used OpenSCAD for years and kept hitting the same walls, so I built exact CAD modelling for GNU Octave

OpenSCAD has served me well, and I still think its idea is right: a part should be a program, not a pile of mouse clicks. But a few of its limits kept biting me:

- **Everything is facets.** A cylinder is $fn sides, so its edges can't be rounded after a boolean, and the part reaches a CAD program as triangles, never as a true cylinder.

- **No fillets or chamfers on the edges you actually have.** Rounding the result of a difference means minkowski or a library trick, and it gets slow.

- **You can't ask a shape anything.** Not its volume, not its size, not where its edges are, so a script can't adapt to its own geometry.

- **No STEP**, so a part can't go to a machinist's CAM or a colleague's CAD with its geometry intact.

- **The language is small.** No real data structures, no numerics, no plotting, so computing anything, a gear profile, a cam, a stress estimate, happens somewhere else.

I'm a GNU Octave developer, so I built the thing I wanted as an Octave package, **drafting**, on top of Open CASCADE, the kernel FreeCAD and CadQuery use. Version 0.2.0 is out today.

Here is the classic CSG example, the cube and sphere with three bores, rebuilt:

body = intersect (solid.box (15, 15, 15, 'Anchor', 'centroid'), solid.sphere (10));
c = solid.cylinder (5, 20, 'Anchor', 'centroid');
S = subtract (body, c, rotate (c, 90, [1, 0, 0]), rotate (c, 90, [0, 1, 0]));
F = fillet (S, edges (S, 'Type', 'circle'), 0.8);
write (F, 'csg.step');
write (F, 'csg.stl');

The fillet line is the one OpenSCAD can't do: the bores' rims are exact circles, so edges finds them by type and `fillet` rounds them. The result goes out as STEP with its curved faces kept, and as STL for the slicer.

OpenSCAD's classic CSG model, rebuilt with exact geometry and every circular edge rounded in one line.

What you keep from OpenSCAD: the part is a script, the booleans read the same union, subtract, intersect, and hull, resize, mirror, text and linear and rotational extrusion with twist and scale are all there. A tutorial for OpenSCAD users maps OpenSCAD's words to the package's, one by one.

What you gain: shapes are values in variables, so a function returns a part and a loop builds an array of them; holes with counterbores and countersinks; shells; lofts and sweeps along 3-D paths; sections that are exact outlines you can extrude again; volume, area and bounding box; assemblies saved to STEP and 3MF with names and colours; and technical drawings to DXF and paper, with dimensions. And it's all inside Octave, so the maths that shapes the part sits in the same script.

Honest limits: it builds on Linux only for now, from source, against Open CASCADE's development packages (one `apt` line on Debian or Ubuntu). There's no editor with a live preview; you call `show` and the viewer window redraws. Windows and macOS are on the roadmap.

- Guide with twelve tutorials: https://pr0m1th3as.github.io/drafting/guide/

- Repository: https://github.com/pr0m1th3as/drafting

I'd really like to hear from OpenSCAD users: which of your models would break first, and what you'd miss.

reddit.com
u/pr0m1th3as — 10 days ago