https://github.com/namachan10777/scad-ml
OpenSCAD DSL for OCaml
https://github.com/namachan10777/scad-ml
Last synced: about 2 months ago
JSON representation
OpenSCAD DSL for OCaml
- Host: GitHub
- URL: https://github.com/namachan10777/scad-ml
- Owner: namachan10777
- License: bsl-1.0
- Created: 2019-01-26T09:43:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-10-04T04:03:29.000Z (over 2 years ago)
- Last Synced: 2025-04-30T20:05:05.189Z (about 2 months ago)
- Language: OCaml
- Size: 595 KB
- Stars: 15
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenSCAD DSL for OCaml
## Overview
This library provides an OCaml front-end to the
[OpenSCAD](https://openscad.org/) solid modelling language. All SCAD primitives
and transformation functions are made available.## Notable differences from the OpenSCAD language
- Angles are represented in radians (and converted to degrees when compiling to
OpenSCAD).
- The dimensional system (2D or 3D) each shape inhabits is tracked by the type
system. This is used to restrict the operations that can be legally applied
(e.g. `linear_extrude` can only be applied to 2D shapes) and enforcing
non-mixing of 2D and 3D shapes during boolean operations.## Usage
``` ocaml
open Scad_mllet 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](https://openscad.org/downloads.html) as you normally would.## Documentation
Online documentation is available
[here](https://namachan10777.github.io/scad-ml/scad_ml/Scad_ml/index.html).## Companion PPX
There is a companion ppx, [\[@@deriving
scad\]](https://github.com/geoffder/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.## Authors
- [@namachan10777](https://github.com/namachan10777)
- Original author
- [@geoffder](https://github.com/geoffder)
- Overhaul and add many functions## License
BSL-1.0