Scad_ml

Scad_ml is an OCaml DSL for the OpenSCAD solid modelling language.

Notable differences from the OpenSCAD language

Usage

open Scad_ml

let () =
  let scad_logo =
    let rad = 5.
    and fn = 720 in
    let cyl = Scad.cylinder ~fn ~center:true ~height:(rad *. 2.3) (rad /. 2.) in
    let cross_cyl = Scad.rotate (v3 0. (Float.pi /. 2.) 0.) cyl in
    Scad.union
      [ Scad.difference
          (Scad.sphere ~fn rad)
          [ cyl; cross_cyl; Scad.rotate (v3 0. 0. (Float.pi /. 2.)) cross_cyl ]
      ; Scad.color ~alpha:0.25 Color.Magenta cross_cyl
      ]
  in
  Scad.to_file "scad_logo.scad" scad_logo

Generated .scad scripts can then be viewed with the OpenSCAD viewer as you normally would, or directly exporting Scad.t into other model formats or PNGs with Scad.export and Scad.snapshot respectively.

API

Scad_ml -- top level library interface

Core DSL

Vectors and transformations

2d paths and polygons

3d paths, coplanar polygons, and meshes

Utilities

Examples

Paths and Sweeps

Rounded Extrusions

Skins and Morphs

Function Plotting

[@@deriving scad]

There is a companion ppx, [@@deriving scad] for generating transformation functions for user-defined records and abstract types made up of the Scad.t, along with their corresponding vector (V2.t or V3.t) types (and those composed of them) provided in this library.