I’d like to announce the first release onto opam of Scad_ml and ppx_deriving_scad. The former being a DSL front-end to the OpenSCAD solid modelling language, and the latter providing transformation function generation for custom types (a pattern that I have found useful during my time using
When I decided I wanted to pick up OpenScad, I was pleasantly surprised to discover that the
Scad_ml library already existed on GitHub, credits to namachan10777 (Nakano Masaki) · GitHub. Over time I filled out the rest of the OpenSCAD language coverage, as well as some additional helpful math, and reorganized things to try and keep it from getting too messy as more and more was tacked on. Finally, after some help in the ocaml discord (from NULL and octachron), we also now can track whether shapes are 2D or 3D with minimal changes to the user interface, preventing misapplications of operations that would otherwise only appear in the OpenSCAD console.
[@@deriving scad] ppx is my solution to make a habit I developed to get around the otherwise fully declarative nature of working in OpenSCAD more ergonomic. Shapes in OpenSCAD cannot be queried in any way, so upon creation, the locations of it’s vertices or it’s origin are not available. Of course, since you created it, you know exactly it’s dimensions, and where you have moved it, but what if you want to use the location of one of it’s vertices, wherever that ends up after a series of transformations? What I did for some time before learning how to write a ppx, was put the coordinates I cared about into a record with the shape, and mapped over the type (by hand (and regex)) with the relevant functions (typically transform and rotate). Turns out writing a ppx with
metaquot isn’t so bad, and I really wish I did it sooner!
Anyway, to the few of you out there that might use OpenSCAD, I hope that these tools might come in handy!