Giter Site home page Giter Site logo

scad-ml's Introduction

OpenSCAD DSL for OCaml

Overview

This library provides an OCaml front-end to the OpenSCAD 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

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

OpenSCAD logo Generated scads can then be viewed with the OpenSCAD viewer as you normally would.

Documentation

Online documentation is available here.

Companion PPX

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.

Authors

License

BSL-1.0

scad-ml's People

Contributors

geoffder avatar namachan10777 avatar smorimoto avatar

Stargazers

Chris Rowe avatar Okawa Yusuke avatar Naoki Kaneko avatar Roman avatar Sacha Froment avatar Mamoru Kamiya avatar  avatar Stéphane Legrand avatar  avatar  avatar Seb Mondet avatar Darren Li avatar Marcello Seri avatar  avatar Mike Panciera avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

scad-ml's Issues

rotate_extrude with ang

When using the rotate_extrude with angle as bellow, it seems missing comma ",".
my code:
Scad.rotate_extrude ~angle:(Float.pi /. 2.) ~convexity:2 ~fn
(Scad.translate(joint_len, 0., 0.)
(Scad.circle ~fn (joint_rad /. 2.)))
the result:
rotate_extrude(angle=90.000000convexity=2, $fn=100)
translate([2.000000, 0.000000, 0.000000])
circle(0.750000, $fn=100);

I think line 423 of scad.ml, (Option.map deg_of_rad angle |> maybe_fmt "angle=%f") should be change to (Option.map deg_of_rad angle |> maybe_fmt "angle=%f, ").

I'm sorry if I sound rude. My English still isn't that good.

OPAM Release (dashboard)

I have just created PR.

Remarks

The v1.0.0 tag and its release have been regenerated. This is because the 2 commits after the original v1.0.0 tag changed the git revision and it makes dune-release fail.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.