stl-parser

0.11.1 • Public • Published

STL Parser

STL-parser is a transform stream which convert STL-files to newline separated JSON events for each face. Check out jsonlines.org for a detailed specification of the jsonl format.

Installation

As a module for your project:

npm install stl-parser

As a command line program:

npm install -g stl-parser

Usage

Command Line Interface

cat test.stl | stl-parser

This emits a jsonl file-stream with header and facet events. The cli flags --ascii and --binary can be used to enforce parsing with the specified file-encoding.

Javascript API

var stlParser = require('stl-parser'),
    stlStream = fs.createReadStream('/path/to/stl/file.stl'),
    outputFile = fs.createWriteStream('/path/to/export/file.jsonl')
 
stlStream
    .pipe(stlParser())
    .pipe(outputFile)

There is also the possibility to use it buffered and get one javascript object for the whole STL. This should, however, only be used for small files.

var stlParser = require('stl-parser'),
    stl = fs.readFileSync('/path/to/stl/file.stl')
 
stlParser(stl).on('data', (data) =>
    fs.writeFileSync('/path/to/export/file.json', data)
)

Dependencies (8)

Dev Dependencies (8)

Package Sidebar

Install

npm i stl-parser

Weekly Downloads

8

Version

0.11.1

License

MIT

Last publish

Collaborators

  • adius
  • steditor
  • atix