A TypeScript library for programmatically building DXF (Drawing Exchange Format) files, suitable for generating CAD drawings in Node.js or browser environments. Latest version 0.1.135 is actively developed with frequent releases. Key differentiators: supports full DXF entities (lines, circles, arcs, text, polylines, blocks), layers, and custom entities; provides a clean builder API; ships with TypeScript definitions; lightweight with no external runtime dependencies. Alternative to complex DXF generators like dxf-writer with a more modern API.
npm install build-dxfNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a DXF drawing with lines, circles, text, layers, and saving to a string or file using build-dxf.
Update code to handle string output, convert to Buffer if needed: Buffer.from(drawing.toDxfString(), 'utf-8')
Use numeric color values: e.g., 1 for red, 2 for yellow, etc.
Convert your coordinates to millimeters before passing to build-dxf functions.
Always specify height when adding text, e.g., { height: 5 }.Use consistent casing when adding and switching layers.
Use ESM import: import dxf from 'build-dxf' or dynamic import: const dxf = await import('build-dxf')Add the layer first using drawing.addLayer(layerName, options), then set it active.
Use default import: import dxf from 'build-dxf'; then new dxf.Drawing(); or named: import { Drawing } from 'build-dxf'; new Drawing();No dependency data recorded yet.