DXF Format: The Complete Technical Guide
DXF (Drawing Interchange Format, also Drawing Exchange Format) is a CAD data file format developed by Autodesk in 1982 for AutoCAD. It was created to enable data interoperability between AutoCAD and other CAD programs. DXF is a text-based (ASCII) or binary format that stores 2D and 3D technical drawings with precise geometric data, dimensions, layers, text, and attributes. Alongside DWG (AutoCAD's native binary format), DXF is the most widely supported CAD exchange format — virtually every CAD, CAM, GIS, and CNC software can read and write DXF.
Historical Context and Versions
Autodesk has released a new DXF version with each major AutoCAD release since 1982. Major versions:
| DXF Version | AutoCAD Version | Year | Key Features Added |
|---|---|---|---|
| DXF R9 | AutoCAD R9 | 1987 | Variables section |
| DXF R12 | AutoCAD R12 | 1992 | Stable baseline, widely compatible |
| DXF R13 | AutoCAD R13 | 1994 | ACIS 3D solids |
| DXF R14 | AutoCAD R14 | 1997 | Improved object model |
| DXF 2000 | AutoCAD 2000 | 1999 | Extension dictionary, proxy entities |
| DXF 2004 | AutoCAD 2004 | 2003 | Password protection capability |
| DXF 2007 | AutoCAD 2007 | 2006 | Improved 3D, DWFX reference |
| DXF 2010 | AutoCAD 2010 | 2009 | Free-form design |
| DXF 2013 | AutoCAD 2013 | 2012 | Coordinate system improvements |
| DXF 2018 | AutoCAD 2018 | 2017 | Current production standard |
Recommendation: For maximum compatibility with third-party software, export as DXF R12 (1992) or DXF 2000/2004. For preserving all modern features, use DXF 2018.
DXF File Structure
An ASCII DXF file is organized as sections, each starting with group code 0 (entity type) and section name "SECTION", ending with "ENDSEC":
HEADER Section
Contains AutoCAD system variables that affect drawing interpretation:
$ACADVER: DXF version string (e.g., "AC1015" = R2000)$INSBASE: Insertion base point (0,0,0)$EXTMIN/$EXTMAX: Drawing extents (bounding box)$LIMMIN/$LIMMAX: Drawing limits$AUNITS: Angle units (0=decimal degrees, 1=degrees/minutes/seconds, 2=grads, 3=radians, 4=surveyor's)$INSUNITS: Drawing units (1=inches, 4=mm, 6=meters, 14=centimeters)$LTSCALE: Global linetype scale$DIMSTYLE: Current dimension style name
CLASSES Section (DXF 2000+)
Defines custom object/entity classes used in the drawing (proxy entities).
TABLES Section
Defines named objects used throughout the drawing:
- LTYPE table: Linetype definitions (solid, dashed, dotted, center, phantom, custom patterns)
- LAYER table: Layer definitions — name, color number (1–255 ACI colors), linetype, lineweight, on/off/frozen state, plot flag
- STYLE table: Text style definitions — font file, height, oblique angle, generation flags
- VIEW table: Named views (position, target, zoom factor)
- UCS table: User Coordinate System definitions
- VPORT table: Viewport configurations
- DIMSTYLE table: Dimension style parameters (arrow size, text height, precision, color, leaders, tolerances)
- BLOCK_RECORD table: Records of all block definitions
BLOCKS Section
Defines reusable block definitions (equivalent to components/symbols). Each block has:
- Block name
- Origin point
- List of entities within the block
Standard blocks: *MODEL_SPACE (model space entities), *PAPER_SPACE (layout entities), named user blocks.
ENTITIES Section
The main drawing content — all geometry objects placed in model space:
LINE: START_POINT (10,20), END_POINT (10,30), LAYER, LINETYPE, COLOR
CIRCLE: CENTER (10,20), RADIUS 5.0, layer attributes
ARC: CENTER, RADIUS, START_ANGLE, END_ANGLE (in degrees, counterclockwise from positive X)
LWPOLYLINE (Lightweight Polyline): A single entity representing a connected sequence of line and arc segments. Most efficient for 2D polygons.
SPLINE: NURBS spline curve. Degree, knot vector, control points, fit points.
ELLIPSE: Center, major axis endpoint, ratio of minor to major axis, start/end parameter.
TEXT: INSERTION_POINT, HEIGHT, TEXT_STRING, rotation angle, style, justification flags.
MTEXT: Multi-line text with RTF-like formatting codes within the text string. Supports bold, italic, paragraph formatting, stacking fractions.
DIMENSION: Dimension entity referencing dimension geometry entities. Types: aligned, rotated, angular, diameter, radius, ordinate.
HATCH: Fill pattern within a closed boundary. Pattern name (ANSI31=metal, ANSI32=steel, ANSI35=earth, SOLID=solid fill), scale, rotation, associative to boundary.
INSERT: Reference to a block definition. Insertion point, scale, rotation, layer.
ATTRIB: Attribute instance within an INSERT entity. Stores parametric text data (title block fields, part numbers, descriptions).
3DFACE: A planar quadrilateral in 3D space (3D mesh faces).
SOLID: Filled 2D quadrilateral or triangle.
OBJECTS Section (DXF 2000+)
Non-graphical objects: dictionaries, image definitions, plot settings, layout definitions, custom data.
Group Codes
DXF uses a group code system — every piece of data has a numeric code indicating its type:
| Group Code Range | Data Type |
|---|---|
| 0 | Entity type, section start |
| 1 | Primary text |
| 2 | Name (block name, attribute tag) |
| 5 | Entity handle (unique hex ID) |
| 6 | Linetype name |
| 7 | Text style name |
| 8 | Layer name |
| 10–19 | X coordinate of point |
| 20–29 | Y coordinate of point |
| 30–39 | Z coordinate of point |
| 40–49 | Floating-point values (radius, height) |
| 50–59 | Angle in degrees |
| 60 | Entity visibility |
| 62 | Color number (ACI: 1=red, 2=yellow, 3=green, 5=blue, 7=white/black, 256=BYLAYER) |
| 70 | Integer flags/counts |
| 100 | Subclass marker (DXF 2000+) |
| 330 | Owner object handle |
| 1000–1071 | Extended data (application-specific) |
Reading and Writing DXF
# Python: read DXF with ezdxf library
import ezdxf
doc = ezdxf.readfile("drawing.dxf")
msp = doc.modelspace()
# Iterate all lines
for entity in msp.query("LINE"):
start = entity.dxf.start # Vec3 object
end = entity.dxf.end
print(f"Line: {start} -> {end}")
# Iterate all layers
for layer in doc.layers:
print(f"Layer: {layer.dxf.name}, Color: {layer.dxf.color}")
# Create a new DXF file
doc = ezdxf.new("R2010")
msp = doc.modelspace()
msp.add_line((0, 0), (100, 100), dxfattribs={"layer": "WALLS"})
msp.add_circle((50, 50), radius=25, dxfattribs={"color": 1})
doc.layers.add("WALLS", color=7)
doc.saveas("output.dxf")
# Convert DXF to SVG with Inkscape
inkscape input.dxf --export-filename=output.svg
# Convert DXF to PDF
inkscape input.dxf --export-filename=output.pdf
# ODA File Converter (free, converts DWG/DXF between versions)
ODAFileConverter input.dxf output_folder DXF ACAD2010 0 1
# LibreCAD (open source CAD, can open and export DXF)
librecad --file input.dxf --export-pdf output.pdf
DXF vs DWG
| Feature | DXF | DWG |
|---|---|---|
| Format | ASCII text (or binary) | Proprietary binary |
| Readability | Human-readable (ASCII) | Not readable without tools |
| Compatibility | Universal (all CAD apps) | AutoCAD-native; others via ODA |
| File size | ~3–5× larger than DWG | Compact binary |
| Version control | Diffable (ASCII) | Binary, not diffable |
| Full AutoCAD feature support | ~95% (some proprietary features lost) | 100% |
| Open specification | Published by Autodesk | Reverse-engineered (Open Design Alliance) |
When to use DXF: For exchanging drawings with non-Autodesk software, CNC machines, laser cutters, vinyl cutters, 3D printers. When to use DWG: For AutoCAD-to-AutoCAD exchange, preserving all proprietary features, collaboration with firms using AutoCAD.
Related conversions
Frequent conversions across the catalogue: