Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @jscad/dxf-deserializer with all npm packages installed. Try it out:

var dxfDeserializer = require("@jscad/dxf-deserializer")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@jscad/dxf-deserializer v0.1.3

DXF deserializer for jscad project

@jscad/dxf-deserializer

DXF deserializer for the JSCAD project

GitHub version Build Status

Overview

This deserializer converts raw DXF data to JSCAD code fragments, or converts raw DXF data directy to CSG library objects. When converting unknown DXF data, converting to JSCAD code fragments will provide more information.

DXF Implementation Notes

The DXF(tm) file structure changes continously as AutoDesk releases new features and fixes. So, you can imagine that after 20 years, the contents of DXF files are pretty messed up. Expect the worst.

NOTE: At this time, only ASCII DXF files are supported. BINARY DXF files are not supported.

This deserializer converts only what is required by JSCAD libraries and applications. Full document conversion is NOT supported, so don't even try. However, conversion of the following DXF entities are possible:

DXF EntityCSG ObjectNotes
3DFACEto CSG
ARCto Path2D
CIRCLEto CAGStart and stop angles are ignored
ELLIPSEto CAGStart and stop angles are ignored
LINEto Line2D or Line3DThis will change in the future
LWPOLYLINEto Path2D or CAGConversion to CAG if LWPOLYLINE is closed
MESHto CSG
POLYLINE (line)to Path2D or CAGConversion to CAG if POLYLINE is closed
POLYLINE (mesh)to CSG
POLYLINE (face)to CSG

In addition, colors are converted using the AutoCad standard color index (256 colors).

Finally, there are many applications that can save to DXF formats. All testing is performed with files from AutoCad, period.

Table of Contents

Installation

npm install @jscad/dxf-deserializer

Usage

const deSerializer = require('@jscad/dxf-deserializer')

const rawData = fs.readFileSync('PATH/TO/file.dxf')
const jscadCode = deSerializer(rawData)

Contribute

For questions about the API, please contact the User Group

PRs accepted.

Small Note: If editing this README, please conform to the standard-readme specification.

License

The MIT License (MIT)

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free