--- title: STL ---

To use this functionality you will need the OpenJsCsg library which is a fork of OpenJsCad without the GUI.

For the browser

{% highlight html %} {% endhighlight %}

Note: This is here for your debugging convenience. For complex models, 3D rendering on the main thread of the browser can make your page unresponsive. It is advised that you use a web worker instead.

For a web worker
{% highlight javascript %} importScripts( 'http://maker.js.org/external/OpenJsCad/csg.js', 'http://maker.js.org/external/OpenJsCad/formats.js' ); {% endhighlight %}

For Node.js

From the command line:

{% highlight bash %} npm install openjscad-csg --save {% endhighlight %}

In your Node.js code:

{% highlight javascript %} var makerjs = require('makerjs'); var fs = require('fs'); var model = new makerjs.models.Star(5, 100); model.paths.c = new makerjs.paths.Circle([0, 0], 20); fs.writeFileSync('star.stl', makerjs.exporter.toSTL(model)); {% endhighlight %}

Simple export

Call makerjs.exporter.toSTL(model) passing your model. This function returns a string of STL.

Advanced options

Call makerjs.exporter.toSTL(model, options) passing your model and an options object.

See the API documentation for OpenJsCad export options