Scad_ml is an OCaml DSL for the OpenSCAD solid modelling language.
linear_extrude
and rotate_extrude
have been renamed to extrude
and revolve
Scad.extrude
can only be applied to 2D shapes) and enforcing non-mixing of 2D and 3D shapes during boolean operations.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.
Scad_ml
-- top level library interface
Scad
-- well-typed dimension aware OpenSCAD modelsText
-- Scad.text
configuration typesColor
-- Scad.color
configuration typeV2
-- 2d vector operationsV3
-- 3d vector operationsAffine2
-- 2d affine transformation matricesAffine3
-- 3d affine transformation matricesQuaternion
-- quaternion manipulation andl applicationPlane
-- normalized cartesian plane operationsPath2
-- generation and manipulation of 2d pathsBezier2
-- 2d bezier curves, patches, and splinesCubicSpline
-- cubic spline interpolation of 2d pathsPoly2
-- 2d polygons (outer, and zero or more inner paths)PolyText
-- point representations of text (via cairo)Path3
-- generation and manipulation of 3d pathsBezier3
-- 3d bezier curves, patches, and splinesPoly3
-- planar 3d polygons (outer, and zero or more inner paths)Mesh
-- points and faces 3d mesh representation (polyhedrons)Math
-- float and 2d matrix operationsExport
-- exporting .scad
scripts via OpenSCAD CLIBallTree2
-- 2d vector space partitioning search treeBallTree3
-- 3d vector space partitioning search treeThere 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.