jscad / openscad-openjscad-translator

DEPRECATED: Convert OpenSCAD to JSCAD (See the link below)
https://github.com/jscad/OpenJSCAD.org/tree/V2/packages
MIT License
22 stars 10 forks source link

openscad-openjscad-translator

GitHub version experimental Build Status Dependency Status devDependency Status

OpenSCAD to OpenJSCAD Translator

Translates OpenSCAD syntax into OpenJsCAD syntax

Overview

Node module that translates OpenSCAD syntax into OpenJSCAD syntax.

IMPORTANT NOTE: This project is written against an older version of OpenSCAD (v 2011.06) which has now been superseded.

The following functions are not implemented (neither in csg.js nor in OpenJSCAD), and contributions are welcome !

Table of Contents

Install

npm install @jscad/openscad-openjscad-translator

NOTE: for now we need to use a temporary build of the sylvester (node-sylvester) library since the one on NPM has a missing flag which makes use with browserify impossible: see : here and here

Usage

Node

  var parser = require('@jscad/openscad-openjscad-translator')
  var fs = require('fs')

  var openSCADText = fs.readFileSync("test.scad", "UTF8")
  var openJSCADResult = parser.parse(openSCADText)

  console.log(openJSCADResult)

Web

  <script src="https://github.com/jscad/openscad-openjscad-translator/raw/master/./dist/web-built.js"></script>

  <script type="text/javascript">
    var text = document.getElementById('txt').innerText
    console.log(openscadOpenJscadParser.parse(text))
  </script>

Include lib/underscore.js and dist/web-built.js and the openscadOpenJscadParser object will be available. This has two attributes:

Build

Web

not minified :

npm run build

minified:

npm run build-min

Creates scripts in the dist folder.

Develop

Jison

npm run build-parser

Compiles the Jison lexer/parser to an AMD module in the src folder called openscad-parser.js.

Contribute

This library is part of the JSCAD Organization, and is maintained by a group of volunteers. We welcome and encourage anyone to pitch in but please take a moment to read the following guidelines.

Small Note: If editing this README, please conform to the standard-readme specification.

License

The MIT License (MIT) (unless specified otherwise)

NOTE: OpenSCAD and OpenSCAD API are released under the General Public License version 2.