10000 GitHub - triroakenshield/dxf: A simple JavaScript interface to DXF written in TypeScript.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

triroakenshield/dxf

 
 

Repository files navigation

DXF (🧩 Still under development 👨🏽‍💻)

GitHub license Build Status Build status CircleCI> Total alerts Language grade: JavaScript GitHub issues npm version

🌟 A simple JavaScript interface to DXF written in TypeScript.

✔️ DXF is a JavaScript library, for Nodejs and Browser, it's for creating DXF files in a simple way.

✨ influenced by 🔗 js-dxf.

  • 🔥 Now it's supporting AC1021 and above.
  • 🔥 Creating minimal dxf content possible.
  • 🔥 Tested on 🔗 AutoCAD, 🔗 LibreCAD and 🔗 DWG FastView on mobile.

🗳️ Install the package

yarn add @tarikjabiri/dxf
# Or npm
npm i @tarikjabiri/dxf

⌨️ Code example

import DXFWriter from "@tarikjabiri/dxf";

const dxf = new DXFWriter();
dxf.addLine(0, 0, 100, 100);
let points = [
    [-300, 0   , 0],
    [0   , 200 , 0],
    [300 , 70  , 0],
    [700 , 100 , 0],
    [1000, 1200, 0]
];
dxf.addLineType('DOT', '. . . . . . . . . . . . . . . . . .', [0,-4])
    .addLineType('ACAD_ISO11W100', '__ __ . __ __ . __ __ .', [4, -2, 4, -2, 0, -2])
    .addLineType('DOT2', '.................................', [0,-2])
    .addLineType('DASHED', '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _', [4,-4]);

dxf.addLayer('l_red',       DXFWriter.colors.Red,       'DASHED')
    .addLayer('l_green',    DXFWriter.colors.Green,     'CONTINUOUS')
    .addLayer('l_cyan',     DXFWriter.colors.Cyan,      'CONTINUOUS')
    .addLayer('l_yellow',   DXFWriter.colors.Yellow,    'ACAD_ISO11W100');

dxf.setCurrentLayer('l_green')
    .addSpline(points, points, 3, 8, [], [])
    .setCurrentLayer('l_red')
    .addCircle(60, 150, 50)
    .addRectangle(20, 20,100, 100)
    .setCurrentLayer('l_cyan')
    .addText(30, 30, 10, "Hello World")
    .addPolyline3D([
        [70, 70, 50],
        [150, 70, 0],
        [170, 170, 150]
    ], 0)
    .addArc(0, 0, 120, 0, 120)
    .addPoint(65, -30, 0)
    .setCurrentLayer('l_yellow')
    .addEllipse(100, 50, 150, 0, 1, 0, 2 * Math.PI)
    .add3DFace(
        0, 0, 10,
        20, 0, 10,
        20, -20, 20,
        0, -20, 20);
// ✔️ To get the dxf string just call the stringify() method
const dxfString = dxf.stringify();

For the priview of the example see 🔗 examples directory.

✔️ Supported entities :

  • ARC
  • CIRCLE
  • ELLIPSE
  • FACE 3D
  • LINE
  • POINT
  • POLYLINE
  • POLYLINE 3D
  • SPLINE
  • TEXT

💉 Colors integrated :

  • Red
  • Green
  • Cyan
  • Blue
  • Magenta
  • White
  • Black
  • Yellow

ℹ️ References used in development :

⚖️ License

MIT license.

💯 Used by :

About

A simple JavaScript interface to DXF written in TypeScript.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 99.8%
  • JavaScript 0.2%
0