This library provides an OCaml front-end to the OpenSCAD solid modelling language. All SCAD primitives and transformation functions are made available.
linear_extrude can only be applied to 2D shapes) and enforcing non-mixing of 2D and 3D shapes during boolean operations.open Scad_ml
let scad_logo =
let rad = 5.
and fn = 720 in
let cyl = Scad.cylinder ~fn ~center:true (rad /. 2.) (rad *. 2.3) in
let cross_cyl = Scad.rotate (0., Float.pi /. 2., 0.) cyl in
Scad.union
[ Scad.difference
(Scad.sphere ~fn rad)
[ cyl; cross_cyl; Scad.rotate (0., 0., Float.pi /. 2.) cross_cyl ]
; Scad.color ~alpha:0.25 Color.Magenta cross_cyl
]
let () =
let oc = open_out "/path/to/things/scad_logo.scad" in
Scad.write oc scad_logo;
close_out oc
Generated scads can then be viewed with the OpenSCAD viewer as you normally would.
Online documentation is available here.
There is a companion ppx, [@@deriving scad] for generating transformation functions for user-defined records and abstract types made up of the Scad.t and Vec3.t types provided in this library.
BSL-1.0