Git Product home page Git Product logo

dxf's Introduction

Build Status

dxf

DXF parser for node/browser.

Uses several ES6 features in the source code (import, classes, let, const, arrows) but is packaged using babel so you can use it legacy JS environments.

Version 2.0 is a complete rewrite from the first attempt to write it in a SAX style, which wasn't really appropriate for a document with nested references (e.g inserts referencing blocks, nested inserts).

Version 3.0 converted the codebase to use standard JS, ES6 imports, stop using Gulp, and updated & removed some dependencies.

At this point in time, the important geometric entities are supported, but notably:

  • MTEXT
  • DIMENSION
  • STYLE

and some others are parsed, but are not supported for SVG rendering (see section below on SVG rendering)

Getting started

There is an ES5 and ES6 example in the examples/ directory that show how to use the library, but there are 3 basic steps:

  1. Parse the DXF contents using dxf.parseString(<contents>). This will return an object representation of the DXF contents.
  2. Denormalise the entities into an array using dxf.denormalize(<parsed>). After Step 1, the entities are still in the block hierarchy of the DXF file, denormalizing will create the resulting entities with the block transforms applied.
  3. (Optional) Create an SVG using dxf.toSVG(<parsed>). Please refer to the SVG section below regarding limitations.

Running the Examples

ES5: $ node examples/example.es5.js

ES6: $ babel-node examples/example.es6.js

SVG

The initial aim of this library was to support rendering of the main geometric components, not dimensions, text, hatches and styles. There is a mechanism for converting the parsed entities to SVG, but they are all converted to polylines, and if you look at the resulting SVG files when running the functional tests, you will see that all entities are rendered as paths.

Here's an example you will find in the functional test output:

svg example image

Tests

Running

$ npm test

will execute the unit tests and functional tests, which generate SVGs for reference DXF files. You can view these SVGs (located in test/functional/output) in a browser or other SVG viewer to see what is supported.

Contributors

dxf's People

Contributors

arjamizo avatar bjnortier avatar liamkarlmitchell avatar shvelo avatar skawaguchi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.