z3dev / Openscad-to-JSCAD-converter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is a converter to convert openscad code to jscad

Getting started

Initial setup

Currently tree-sitter-openscad requires Python (it might be possible to remove this requirement by compiling the parser to wasm)

git clone https://github.com/cookiecad/Openscad-to-JSCAD-converter.git 
cd Openscad-to-JSCAD-converter
npm i

Usage

node ./converter/index.js ./test-files/custom-honeycomb-wall-v2.1.scad

This will create the jscad file and some other formats in the output folder. You can view the result by copying the contents of ./output/output-cadit.js to cadit.app. Click "Add your own", paste the results and click generate.

How it works Openscad code is parsed using the tree-sitter-openscad library. grammarToJscadSyntax.js converts the openscad grammar to jscad syntax. This is mostly used as a starting point and allows simple mappings to work without additional code. Mode complex syntax conversions are done by overriding the generated syntax in jscadSyntax.js

Other parser / generator tools considered

Nearly Peg.js

About


Languages

Language:JavaScript 93.8%Language:OpenSCAD 6.2%