Skip to content
This repository has been archived by the owner on May 28, 2022. It is now read-only.

jscad/openscad-openjscad-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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="../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:

  • parse - a function which accepts OpenSCAD text and returns OpenJsCAD text.
  • parser - a Jison parser object which can be used for more advanced parsing (e.g. the parse method returns the text and the context object, allowing for processing of use statements.)

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.

  • If you want to submit a bug report please make sure to follow the Reporting Issues guide. Bug reports are accepted as Issues via GitHub.

  • If you want to submit a change or a patch, please see the Contributing guide. New contributions are accepted as Pull Requests via GithHub.

  • We only accept bug reports and pull requests on GitHub.

  • If you have a question about how to use OpenJSCAD, then please start a conversation at the OpenJSCAD.org User Group. You might find the answer in the OpenJSCAD.org User Guide.

  • If you have a change or new feature in mind, please start a conversation with the Core Developers and start contributing changes.

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.