package OSCADml

  1. Overview
  2. Docs
OCaml DSL for 3D solid modelling in OpenSCAD

Install

Dune Dependency

Authors

Maintainers

Sources

OSCADml-0.1.0.tbz
sha256=46b6292757a8095a506f629da1588a3c853e3e18e580f5595b855de75058ac39
sha512=2e8ce81bb4656a7901a725414f7f60c66da497dfc4f5d3fb1c1bd1c33f803b7d35143055547046ba2264b61bb67587335409605c0cd7174305500be1f43b8c7e

doc/OSCADml/OSCADml/Export/index.html

Module OSCADml.ExportSource

Exporting .scad scripts through the OpenSCAD command line interface.

2D/3D formats

Sourceval script : string -> string -> (unit, string) result

script out_path in_path

Export the .scad script at in_path to a file at the given out_path, in a format dictated by the extension of out_path. See documentation for the -o argument in the OpenSCAD CLI docs for available output formats. If export fails, an error containing captured Stderr output from OpenSCAD is returned (usually CGAL errors).

Images (PNG)

Sourcetype colorscheme =
  1. | Cornfield
  2. | Metallic
  3. | Sunset
  4. | Starnight
  5. | BeforeDawn
  6. | Nature
  7. | DeepOcean
  8. | Solarized
  9. | Tomorrow
  10. | TomorrowNight
  11. | Monotone

OpenSCAD colour palettes

Sourcetype projection =
  1. | Perspective
  2. | Orthogonal

View projection (as in OpenSCAD GUI)

Sourcetype view =
  1. | Axes
  2. | Crosshairs
  3. | Edges
  4. | Scales
  5. | Wireframe

View options (as in OpenSCAD GUI)

Sourcetype camera =
  1. | Auto
    (*

    Automatically positon to view all of the object, and point at it's centre.

    *)
  2. | Gimbal of {
    1. translation : OCADml.v3;
      (*

      origin shift vector

      *)
    2. rotation : OCADml.v3;
      (*

      euler rotation vector (about translated origin)

      *)
    3. distance : [ `Auto | `D of float ];
      (*

      vertical distance of camera above shifted origin before rotation (auto moves far enough away to bring object fully into frame)

      *)
    }
  3. | Eye of {
    1. lens : OCADml.v3;
      (*

      lens position vector

      *)
    2. center : OCADml.v3;
      (*

      center position vector (which lens points towards)

      *)
    3. view_all : bool;
      (*

      override vector distance to ensure all object is visible

      *)
    }

Camera position and orientation configuration

Sourceval auto : camera

Position camera such that object is centred and fully in view.

Sourceval gimbal : ?translation:OCADml.v3 -> ?rotation:OCADml.v3 -> [ `Auto | `D of float ] -> camera

gimbal ?translation ?rotation d

Position and orient the camera as in the OpenSCAD GUI with translation, and euler rotation vectors a (defaulting to V3.zero). The focal point is moved from the origin by translation, then the camera is positioned the distance d (manually, or far enough back to get the whole object into frame) straight upward in z before applying the euler rotation.

Sourceval eye : ?view_all:bool -> ?center:OCADml.v3 -> OCADml.v3 -> camera

eye ?view_all ?center lens

Position the camera at lens, and point it at center. If view_all is true, then the camera will be moved along the difference vector to bring the whole object into the frame.

Sourceval snapshot : ?render:bool -> ?colorscheme:colorscheme -> ?view:view list -> ?projection:projection -> ?size:(int * int) -> ?camera:camera -> string -> string -> (unit, string) result

snapshot ?render ?colorscheme ?view ?projection ?size ?camera out_path in_path

Save an image (PNG only at this time) of size pixels (default = (500, 500)) to out_path of the object defined by the .scad script located at in_path using the OpenSCAD CLI. By default, the camera is positioned automatically to point at the centre of the object, and far enough away such for it to all be in frame. See camera and its gimbal and eye constructors for details on manual control. If export fails, an error containing captured Stderr output from OpenSCAD is returned (usually CGAL errors).

  • if render is true, the object will be rendered before the snapshot is taken, otherwise preview mode is used (default = false).
  • view toggles on various viewport elements such as axes and scale ticks
  • projection sets the view style as in the GUI (default = Perspective)
  • colorscheme selects the OpenSCAD colour palette (default = Cornfield)

File extension helpers

Sourcemodule ExtMap : Map.S with type key = string
Sourcetype ext2 = [
  1. | `Csg
  2. | `Dxf
  3. | `Svg
]
Sourcetype ext3 = [
  1. | `Amf
  2. | `Csg
  3. | `Off
  4. | `Stl
  5. | `Wrl
  6. | `_3mf
]
Sourceval d2_exts : [> ext2 ] ExtMap.t

Set of 2D output format file extensions: ".dxf", ".svg", ".csg"

Sourceval d3_exts : [> ext3 ] ExtMap.t

Set of 3D output format file extensions: ".stl", ".off", ".amf", ".3mf", ".csg", ".wrl"

legal_ext allowed path

Check whether the extention of the file at path is in the allowed, returning it as the error string if not.

OCaml

Innovation. Community. Security.