The DXF File Specification

Updated Jul 31, 2017
DXF File Specification

All file formats have a specification that describes how the information is encoded in the file — how bytes are arranged, how your computer loads the file and so on. The DXF file format is a vector graphic file format, and its specification details how different drawing elements are represented. Each CAD program then interprets this set of instructions and reproduces your vector drawing. Its creator, AutoDesk, publishes these official file specification documents, which defines the syntax (or a set of rules) that define a DXF file. In this article, I introduce the basic setup & specification of a DXF file.

Representation of data using group codes and values

Every variable in the DXF file is associated with a group code (there are group codes ranging from 1 to 1071); each group code is used in a certain situation and contain specific types of information. For example, group code 2 is used for names, such as names of sections or names of blocks. Group code 0 refers to the start of an entity or the end of the file.

The values associated with each variable are stored as an integer, floating-point number or a string. For example, the length of a line is stored as an integer, while point coordinates are stored as a floating point number.

File structure

A DXF file is organized into several sections; each section is composed of records, which in turn are composed of a group code and associated data values. Here are the sections you’ll find in a DXF file – in the following order:

Section Basic description
Header This section contains general information about the drawing. It’s like the Settings functionality in your phone, which contains the different variables associated with the drawing and its associated values. For example, the Header section will define which AutoCAD version the DXF file uses (the $ACADVER variable) or the unit used to measure angles in the file (the $AUNITS variable)
Classes The CLASSES section holds the information for application-defined classes whose instances appear in the BLOCKS, ENTITIES, and OBJECTS sections of the database.

This section contains definitions for several different tables, each of which contains a number of different symbol entries. For example the line type table (LTYPE) defines the pattern of dashes, dots, text and symbols in the DXF file and how they’re scaled. Here is a complete list of tables found in this section:

  • Application ID (APPID) table
  • Block Record (BLOCK_RECORD) table
  • Dimension Style (DIMSTYPE) table
  • Layer (LAYER) table
  • Linetype (LTYPE) table
  • Text style (STYLE) table
  • User Coordinate System (UCS) table
  • View (VIEW) table
  • Viewport configuration (VPORT) table
Blocks This section contains the graphical objects and drawing entities that make up each block reference in the drawing.
Entities This section contains the actual object data and graphical entities of the drawing. This can include raw data – for example, a circle entity is defined by its thickness, the center point, its radius and extrusion direction.
Objects Here, you’ll find the the non-graphical parts of the drawing. For example, AutoCAD dictionaries are stored here.

Walkthrough of a DXF file

Let’s pretend to be a computer and “read” a DXF file together. You can actually open DXF files with any text editor such as Notepad, and the information will be presented this way.

DXF File format - File structure with group codes and sections

Can you spot the Header section and the different group codes and values in it?


Where can I download the complete DXF file specification?

DXF File Format — Specification Screenshot Good news, the DXF file format is an open-sourced file format! This means that the official DXF specification document is available online, free of charge, for every developer who is looking to read or write a DXF file. The openness of the DXF file is what makes it such a widely supported drawing file in the CAD world.

DXF file specification varies from release to release. There are minor changes in each release, such as new types of drawing elements and group codes are added. Newer programs can usually read older files whereas older programs cannot read newer files. For example, an AutoCAD 2010 user can read a 2006 DXF file, but he cannot read a 2012 DXF file.

These frequent updates can lead to compatibility issues. If you’re coming up with an error while reading your DXF file, it could be that the program that wrote that particular DXF file used an older specification document. Some applications also skip over unsupported features – so be careful that you aren’t losing any information when exporting and importing DXF files!

Indeed, the DXF file format is a difficult format to interpret, mainly because it contains so many different types of data. However, it is structured such that developers and programs can read sections they need, and skip over the elements that they don’t need.

Still got questions about DXF files? Why not check out our guide to frequently asked questions about the DXF file format?

scan2cad advert for free trial