Introduction
DWG is the native drawing format of AutoCAD, which Autodesk released in the early 1980s. It holds two and three dimensional drawings for architecture, engineering and manufacturing: lines, arcs, text, dimensions, blocks, layers and layouts for printing. It is one of the most widely used CAD formats.
Autodesk does not publish the format. Other programs read and write it using libraries built by studying the files, such as the Open Design Alliance’s SDK and the free LibreDWG. The Open Design Alliance publishes its findings as the Open Design Specification for .dwg files, which this site’s reference pages follow.
Structure
A DWG file starts with six ASCII characters that name the format version. From Release 13 on, most of the file is a bit stream in which common values take only a few bits, and every object is found through a handle. R13 to R2000 files hold their sections in place, found through a table at the start; from R2004 the file is split into pages, with an encrypted header, page and section maps and compression, and R2007 adds Reed-Solomon error correction.
| Version string | Release | Written by (LibreDWG’s list) |
|---|---|---|
AC1012 | R13 | AutoCAD Release 13 |
AC1014 | R14 | AutoCAD Release 14 |
AC1015 | R2000 | AutoCAD 2000 |
AC1018 | R2004 | AutoCAD 2004 to 2006 |
AC1021 | R2007 | AutoCAD 2007 to 2009 |
AC1024 | R2010 | AutoCAD 2010 to 2012 |
AC1027 | R2013 | AutoCAD 2013 to 2017 |
AC1032 | R2018 | AutoCAD 2018 to 2021 |
The release names come from the ODA specification and the “written by” ranges
from LibreDWG’s version table. LibreDWG lists AutoCAD 2000i and 2002 under their own
strings, AC1016 and AC1017, and records no newer format
than AC1032. Files from before Release 13 use a different layout that
the ODA specification does not cover.
In this reference
- File structure – version strings, the R13 to R2000 file header and section locators with a worked example, the R2004 encrypted header, page map, section map, page headers and compression, and the R2007 header, maps, compression, CRCs and Reed-Solomon coding
- Bit codes and data types – every data type code, bitshorts, bitlongs, bitdoubles, modular chars and shorts, colours, object types, handle references, strings and the CRCs, with examples
- Header variables and classes – every header variable in file order with its type and versions, the flags word, and the classes section for each version
- Objects and entities – the common object and entity formats, the string stream, every fixed type number, a worked R14 example, the fields of the main entities and table objects, extended entity data and proxy graphics
- Further objects – LEADER, VIEW, UCS, VPORT, MLINESTYLE, LAYOUT, IDBUFFER, IMAGE, IMAGEDEF, IMAGEDEFREACTOR, LAYER_INDEX, RASTERVARIABLES, SCALE, SORTENTSTABLE and PROXY, with their DXF group codes
- Other data sections – the object map, second header, auxiliary header, preview, summary info, app info, file dependencies, security, template, object free space and data storage
The reference pages follow version 5.4.1 of the Open Design Alliance’s specification, which covers R13 to R2018. Its chapter 20 describes more objects than the pages reproduce so far; the objects page lists them.
Not described
Known, not yet covered
- Reference: the field layouts of about 30 object types that chapter 20 of the ODA specification describes and the objects page lists with their section numbers: MLEADER and its annotation context and style, DIMSTYLE, the viewport entity header, HATCH, FIELD and FIELDLIST, GEODATA, OLE2FRAME, the object context data types, SPATIAL_FILTER and SPATIAL_INDEX, and the TABLE, table content and table style family. (LEADER, VIEW, UCS, VPORT, MLINESTYLE, LAYOUT, IDBUFFER, IMAGE and its definitions, LAYER_INDEX, RASTERVARIABLES, SCALE, SORTENTSTABLE and PROXY are on the Further objects page.)
- Viewer: none yet; the site shows the hex viewer only.
Unknown
- Reference: the bit codes EC, S, L and D, which the specification’s object prescriptions use but its chapter 2 never defines (details), and the colour coding that the specification gives two ways for R2000.
- Reference: the header, file header and section values that the specification itself labels unknown, such as several unlabelled BD, BL and TV fields (header page).
- Reference: the layout of files from before Release 13, which the ODA specification does not cover.
Links
Software
- AutoCAD – Autodesk’s CAD program, which saves DWG drawings (Windows, macOS)
- Autodesk viewers – free viewers, including DWG TrueView (Windows, web)
- BricsCAD – CAD program that works natively in DWG (Windows, macOS, Linux)
Developers
- Open Design Alliance – Drawings SDK for reading and writing DWG, for members (C++)
- LibreDWG – free library and command line tools for DWG (C)
Reference
- Open Design Specification for .dwg files – the Open Design Alliance’s description of the format from R13 to R2018, version 5.4.1
- LibreDWG manual – documentation of the free DWG library and its tools