Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:DXF

From ReverseEngineering.wiki
Format
Vendor Autodesk
Magic ASCII: none (starts with group code 0 or 999); binary: "AutoCAD Binary DXF\r\n\x1a\0"
Extensions .dxf
On this wiki Facts · Code · Notes · Topics

AutoCAD Drawing Exchange Format (.dxf): ASCII group-code/value line pairs in HEADER, CLASSES, TABLES, BLOCKS, ENTITIES and OBJECTS sections, or the binary variant that starts with "AutoCAD Binary DXF\r\n\x1a\0".

ASCII structure

ASCII DXF is a sequence of line pairs: a line holding an integer group code, then a line holding the value. ezdxf's low-level reader (src/ezdxf/lldxf/tagger.py ascii_tags_loader, lines 88-132) reads two lines at a time, converts the first with int() (a non-integer is a structure error), strips the trailing newline of the second, treats group code 999 as a comment (skipped by default) and stops at the pair 0 / EOF, ignoring any data after it.

The file is divided into sections, each opened by 0 SECTION / 2 NAME and closed by 0 ENDSEC. ezdxf lists the sections it manages as HEADER, CLASSES, TABLES, BLOCKS, ENTITIES, OBJECTS and ACDSDATA (src/ezdxf/lldxf/const.py MANAGED_SECTIONS).

The HEADER section holds variables named $NAME; $ACADVER carries the same 6-byte version string as the first bytes of a DWG, for example AC1009 (R12), AC1015 (R2000), AC1018 (R2004), AC1021 (R2007), AC1024 (R2010), AC1027 (R2013), AC1032 (R2018); see Format:DWG. ezdxf's const.py lines 6-16 define DXF9 = AC1004, DXF10 = AC1006, DXF12 = AC1009, DXF13 = AC1012, DXF14 = AC1014 and the later ones above.

Binary DXF

A binary DXF starts with the 22 bytes AutoCAD Binary DXF\r\n\x1a\x00 (ezdxf tagger.py lines 134-157). After that come the same tags in binary form: the reader scans the first 1024 bytes for the $ACADVER and $DWGCODEPAGE names to learn the version and text encoding, defaulting to AC1009 and cp1252 (lines 159-190). Files at AC1021 or later use UTF-8. For AC1009 and older the group code is 1 byte (255 introduces an extended-data code held in the next 2 bytes); for newer files it is a 2-byte little-endian value (lines 196-210). The value type follows from the group code (src/ezdxf/lldxf/types.py lines 77-111):

Group codes Value
290-299 1 byte (bool)
60-79, 170-179, 270-289, 370-389, 400-409, 1060-1070 int16
90-99, 420-459, 1071 int32
160-169 int64
10-59, 110-149, 210-239, 460-469, 1010-1059 double
310-319, 1004 binary chunk: 1-byte length, then the bytes
anything else zero-terminated string in the file's encoding

All numbers are little-endian (struct format <h, <i, <q, <d).

Tools and sources

ezdxf (MIT): https://github.com/mozman/ezdxf

Unverified: ASCII files written by AutoCAD start with 0 / SECTION (some begin with a 999 comment line); no magic exists to tell ASCII DXF from other text without parsing.

Code & repositories

  • https://github.com/LibreDWG/libredwg @ f860b0fb76d5f8effb5a70769a3389cb1e0308c8 · license: GPL-3.0-or-later (declared by the contributor for the files used; GitHub reports GPL-3.0 for the repository)
    GNU LibreDWG, DWG reader/writer; src/common.c version table and src/decode.c R2004 header
    Tested on: source read, not run: source read only · checked 2026-10-19; last activity 2026-10-13; Note: the latest release ships binaries; the wiki links only the source, never the binaries
  • https://github.com/mozman/ezdxf @ 748e211c9a0b977b9e15845a6bcad8e1b9743e26 · license: MIT
    Python DXF library; low-level ASCII and binary tag loaders
    Tested on: source read, not run: source read only · checked 2026-10-19; last activity 2026-10-18

See also

Format:DWG