Skip to content
Ben Zuill-Smith edited this page Apr 27, 2015 · 3 revisions

Dxf-Parser

Samples

This repository contains a sample dxf at samples/data/api-cw750-details.dxf and basic sample code to demonstrate how to use this parser at samples/parse-sync.js and samples/parse-stream.js. To use them, clone the repository, cd into samples, and run

node parse-sync
// OR
node parse-stream

This will create a file called out.json in the current directory. Open it to see the result of parsing the sample dxf mentioned above.

How To Contribute

Anyone is welcome to contribute. Simply clone this repository, make your changes and create a pull request.

We prefer it if changes come with tests. Tests are run using mocha in the BDD style. See the test directory for samples.

It can be difficult debug the parser code for large files. To aid developmenet, you can uncomment a line near the top of lib/DxfParser.js to enable debug logs.

//log.setLevel('debug'); // Uncomment for verbose tracing
//log.setLevel('info'); // Uncomment for regular output

The debug logs will be a verbose tracing of the parser's progress. The output of these logs usually needs to be redirected to a file. For example node samples/parse-sync.js > out.log. Some useful output is sent to console.error so it may be good to redirect that to out.log as well.

Some sample output of the debug logs

LINE {
}
MTEXT {
unhandled group 100:AcDbMText
unhandled group 46:0
unhandled group 7:FG-Note
unhandled group 73:1
unhandled group 44:1
}

The above output shows 2 entities that were parsed. First was a LINE entity. All it's properties were handled properly by the parser. The second is the MTEXT entity. It had 5 unhandled code:value pairs (called groups). You can read the AutoCad DXF Reference (pdf download) to determine what these codes mean and can edit the parser to include these values with logical names.

Some key items that we could use some help with:

  • Writing tests for current code
  • Writing a build script to compile the code for browsers (probably using browserify but we are open to ideas)
  • See our issues page for other things to work on
Clone this wiki locally