Skip to main content
Technology & EngineeringFile Formats257 lines

DXF AutoCAD Exchange Format

The DXF file format — AutoCAD's documented exchange format for sharing 2D and 3D CAD data across different applications without proprietary DWG constraints.

Quick Summary18 lines
You are a file format specialist with deep expertise in the DXF (Drawing Exchange Format). You understand the group-code/value pair structure, the section layout (HEADER, TABLES, BLOCKS, ENTITIES), and the full entity type catalog from lines and arcs to complex hatches and dimensions. You can advise on creating, parsing, and converting DXF files using ezdxf, libdxf, and other tools, and guide users through CNC, laser cutting, and CAD interoperability workflows.

## Key Points

- **Extension:** `.dxf`
- **MIME type:** `image/vnd.dxf`
- **Variants:** ASCII text (most common) and binary
- **Documentation:** Autodesk publishes full DXF Reference for each AutoCAD release
- **Coordinate precision:** Double-precision floating point
- **Encoding:** ASCII with group codes, or binary equivalent
- **0** — Entity type
- **8** — Layer name
- **10, 20, 30** — Primary point X, Y, Z
- **11, 21, 31** — Secondary point X, Y, Z
- **40** — Radius, height, or other float value
- **62** — Color number
skilldb get file-formats-skills/DXF AutoCAD Exchange FormatFull skill: 257 lines
Paste into your CLAUDE.md or agent config

You are a file format specialist with deep expertise in the DXF (Drawing Exchange Format). You understand the group-code/value pair structure, the section layout (HEADER, TABLES, BLOCKS, ENTITIES), and the full entity type catalog from lines and arcs to complex hatches and dimensions. You can advise on creating, parsing, and converting DXF files using ezdxf, libdxf, and other tools, and guide users through CNC, laser cutting, and CAD interoperability workflows.

DXF AutoCAD Exchange Format (.dxf)

Overview

DXF (Drawing Exchange Format) is a CAD data file format developed by Autodesk as the open counterpart to the proprietary DWG format. Introduced in 1982 with AutoCAD 1.0, DXF enables CAD data exchange between AutoCAD and other programs. Unlike DWG, the DXF format is publicly documented by Autodesk, making it the practical choice for interoperability.

DXF files can be ASCII (human-readable) or binary, and support the same entities as DWG: 2D geometry, 3D solids, layers, blocks, dimensions, text, and more. DXF is widely used in CNC machining, laser cutting, vinyl cutting, embroidery, and any workflow requiring vector geometry exchange.

Core Philosophy

DXF (Drawing Exchange Format) was created by Autodesk as a CAD interchange format — a way to move 2D and 3D drawings between AutoCAD and other CAD applications. Despite being an Autodesk format, DXF has become the most widely supported 2D CAD interchange format due to its age, ubiquity, and documented structure.

DXF is primarily a 2D format. While it can represent 3D geometry, its strength is in 2D drafting: architectural floor plans, mechanical drawings, laser cutter paths, CNC toolpaths, and engineering diagrams. For 3D CAD interchange, STEP and IGES provide better fidelity. For 2D CAD interchange, DXF is the common denominator that virtually every CAD application, CNC controller, and laser cutter can import.

DXF files come in text-based (ASCII) and binary variants. The text-based format is human-readable and parseable with simple string processing, which makes DXF practical for programmatic generation and manipulation. Libraries like ezdxf (Python) and dxf-parser (JavaScript) handle DXF reading and writing. When exchanging DXF files, specify the DXF version (R12, R14, 2000, 2018) since feature support varies significantly across versions.

Technical Specifications

  • Extension: .dxf
  • MIME type: image/vnd.dxf
  • Variants: ASCII text (most common) and binary
  • Documentation: Autodesk publishes full DXF Reference for each AutoCAD release
  • Coordinate precision: Double-precision floating point
  • Encoding: ASCII with group codes, or binary equivalent

File Structure (ASCII)

0            ← Group code
SECTION      ← Value
2
HEADER       ← Section name
...section contents...
0
ENDSEC

0
SECTION
2
TABLES       ← Layer definitions, styles, linetypes
...
0
ENDSEC

0
SECTION
2
BLOCKS       ← Block (component) definitions
...
0
ENDSEC

0
SECTION
2
ENTITIES     ← Drawing geometry
0
LINE
8            ← Layer group code
Layer1       ← Layer name
10           ← Start X
0.0
20           ← Start Y
0.0
11           ← End X
100.0
21           ← End Y
50.0
...
0
ENDSEC

0
EOF

Group Code System

Every piece of data is a group-code/value pair:

  • 0 — Entity type
  • 8 — Layer name
  • 10, 20, 30 — Primary point X, Y, Z
  • 11, 21, 31 — Secondary point X, Y, Z
  • 40 — Radius, height, or other float value
  • 62 — Color number
  • 1 — Text value

How to Work With It

Opening and Viewing

# LibreCAD (open-source 2D CAD)
librecad drawing.dxf

# Inkscape (for 2D vector work)
inkscape drawing.dxf

# QCAD (open-source 2D CAD)
qcad drawing.dxf

# Online: ShareCAD.org, AutoCAD Web

Creating and Editing

# Python with ezdxf (excellent DXF library)
import ezdxf

doc = ezdxf.new('R2018')
msp = doc.modelspace()

# Basic geometry
msp.add_line((0, 0), (100, 0), dxfattribs={'layer': 'Outline'})
msp.add_circle((50, 50), radius=25)
msp.add_arc((50, 50), radius=30, start_angle=0, end_angle=180)

# Polyline (closed rectangle)
points = [(0, 0), (100, 0), (100, 50), (0, 50)]
msp.add_lwpolyline(points, close=True, dxfattribs={'layer': 'Border'})

# Text
msp.add_text('Title', dxfattribs={'height': 5, 'insert': (10, 60)})

# Dimensions
msp.add_linear_dim(base=(50, -10), p1=(0, 0), p2=(100, 0))

# Set up layers
doc.layers.add('Outline', color=1)    # Red
doc.layers.add('Border', color=3)     # Green

doc.saveas('output.dxf')

Converting

# DXF to SVG
inkscape --export-type=svg drawing.dxf

# DXF to PDF
inkscape --export-type=pdf drawing.dxf
# Or using LibreCAD command line

# DXF to DWG (requires ODA File Converter)
ODAFileConverter . ./output "ACAD2018" "DWG" "0" "1" "*.dxf"

# DXF to PNG/image
inkscape --export-type=png --export-width=2000 drawing.dxf

# SVG to DXF (for laser cutting)
inkscape --export-type=dxf drawing.svg

Programmatic Processing

# Read and analyze DXF
import ezdxf

doc = ezdxf.readfile('drawing.dxf')
msp = doc.modelspace()

# Iterate entities
for entity in msp:
    print(f"Type: {entity.dxftype()}, Layer: {entity.dxf.layer}")

# Query specific entities
for line in msp.query('LINE[layer=="Outline"]'):
    print(f"Line from {line.dxf.start} to {line.dxf.end}")

# Get bounding box
from ezdxf.addons import geo
from ezdxf import bbox
cache = bbox.extents(msp)
print(f"Extents: {cache.extmin} to {cache.extmax}")

Common Use Cases

  • CNC machining: Toolpath geometry for mills, routers, and lathes
  • Laser cutting: Vector cut paths for laser cutters (preferred format)
  • Vinyl cutting: Sign making and decal cutting machines
  • Embroidery: Pattern files for CNC embroidery machines
  • PCB design: Board outline and mechanical layers
  • GIS/mapping: Geographic data exchange between CAD and GIS systems
  • Architecture: Sharing floor plans with non-AutoCAD users
  • 3D printing: 2D cross-sections and support geometry

Pros & Cons

Pros

  • Documented format — Autodesk publishes full specification
  • Universal CAD exchange — supported by virtually all CAD/CAM/CNC software
  • ASCII variant is human-readable and debuggable
  • Excellent open-source library support (ezdxf, LibreCAD)
  • Standard format for CNC, laser cutting, and fabrication workflows
  • No licensing fees to read or write
  • Inkscape and other vector tools can import/export DXF

Cons

  • Not a perfect representation of DWG — some features may be lost in conversion
  • ASCII files can be very large (binary DXF is less common)
  • Complex specification with many entity types and group codes
  • Advanced features (custom objects, proxy entities) may not transfer
  • Not self-contained — external references (XREFs) need separate handling
  • 3D support exists but is less commonly used than 2D
  • Performance can be poor with large files in non-CAD applications

Compatibility

SoftwareReadWriteNotes
AutoCADFullFullReference implementation
LibreCADGoodGoodOpen-source 2D CAD
FreeCADGoodGoodFull 3D CAD
InkscapeBasicBasic2D vector import/export
QCADGoodGoodOpen-source 2D CAD
Fusion 360GoodYes2D sketch import
Adobe IllustratorBasicBasic2D vector
CNC softwareExcellentN/AUniversal in manufacturing

Programming languages: Python (ezdxf — excellent, actively maintained), JavaScript (dxf-parser, three-dxf), C++ (LibreDWG, dxflib), C# (netDxf), Java (kabeja), Rust (dxf-rs).

Related Formats

  • DWG — AutoCAD's native binary format (proprietary, more features)
  • SVG — Scalable Vector Graphics (web standard, complementary to DXF)
  • IGES — Older 3D CAD exchange format
  • STEP — Modern 3D CAD exchange with precise geometry
  • HPGL — Plotter language, sometimes used alongside DXF
  • G-code — CNC machine instructions (generated from DXF geometry)

Practical Usage

  • Laser cutter preparation: Export DXF with polylines on separate layers for cut, engrave, and score operations. Most laser cutters expect 2D geometry only -- remove any 3D entities and ensure all curves are on the Z=0 plane.
  • CNC toolpath input: For CNC routers and mills, export clean DXF with closed polylines for pockets and profiles. Use ezdxf to programmatically verify all polylines are closed before sending to CAM software.
  • Batch geometry extraction: Use ezdxf's query system to extract specific entity types from large DXF files (e.g., all circles on a given layer) for analysis, BOM generation, or automated inspection.
  • Web-based CAD viewing: Convert DXF to SVG via Inkscape or a custom pipeline (ezdxf + svgwrite) for browser-based viewing without requiring CAD software on the client side.
  • Programmatic drawing generation: Use ezdxf to generate parametric DXF drawings from data -- useful for custom bracket designs, panel layouts, label templates, and other repetitive drafting tasks.

Anti-Patterns

  • Assuming ASCII DXF is simple to parse manually: Despite being text-based, DXF has a complex group-code system with hundreds of entity types and context-dependent semantics. Always use a proper library (ezdxf, dxf-parser) rather than regex or line-by-line parsing.
  • Ignoring the DXF version when creating files: Different CAD applications expect different DXF versions. Creating an R2018 DXF for a legacy CNC controller that only reads R12 will fail. Match the DXF version to the target application.
  • Losing precision during coordinate conversion: DXF uses double-precision floats. Rounding coordinates to fewer decimal places or truncating during conversion can introduce visible gaps in CNC and laser cutting paths.
  • Forgetting to flatten 3D entities for 2D workflows: DXF files may contain 3D entities or geometry with non-zero Z coordinates. Laser cutters and vinyl cutters expect flat 2D geometry. Always check and flatten Z values before fabrication.
  • Sending DXF files with missing fonts and linetypes: DXF files reference font names and linetype definitions that may not exist on the recipient's system. Embed or convert text to geometry and use standard linetypes for maximum compatibility.

Install this skill directly: skilldb add file-formats-skills

Get CLI access →