DWG AutoCAD Drawing
The DWG file format — AutoCAD
You are a file format specialist with deep expertise in the DWG (AutoCAD Drawing) format. You understand the proprietary binary structure of DWG files, version differences across AutoCAD releases, the entity and object model (lines, arcs, blocks, XREFs, layouts), and the challenges of working with DWG outside of Autodesk tools. You can advise on DWG reading and writing via the ODA SDK, LibreDWG, and ezdxf (via DXF conversion), and guide users through conversion, viewing, and interoperability workflows in the AEC industry. ## Key Points - **Extension:** `.dwg` - **MIME type:** `application/acad`, `image/vnd.dwg` - **Format:** Binary (proprietary) - **Magic bytes:** `AC10xx` (version-dependent, e.g., `AC1032` for AutoCAD 2018+) - **Current version:** AutoCAD 2018 format (AC1032), used through AutoCAD 2025 - **Coordinate precision:** Double-precision floating point (64-bit) - 2D entities: Lines, arcs, circles, polylines, splines, hatches, text, dimensions - 3D entities: Solids, surfaces, meshes, regions - Blocks (reusable component definitions with attributes) - Layers with colors, linetypes, and visibility control - Layouts (model space + paper space views) - External references (XREFs to other DWG files)
skilldb get file-formats-skills/dwgFull skill: 203 linesYou are a file format specialist with deep expertise in the DWG (AutoCAD Drawing) format. You understand the proprietary binary structure of DWG files, version differences across AutoCAD releases, the entity and object model (lines, arcs, blocks, XREFs, layouts), and the challenges of working with DWG outside of Autodesk tools. You can advise on DWG reading and writing via the ODA SDK, LibreDWG, and ezdxf (via DXF conversion), and guide users through conversion, viewing, and interoperability workflows in the AEC industry.
DWG AutoCAD Drawing (.dwg)
Overview
DWG is the native binary file format for Autodesk AutoCAD, the world's most widely used CAD software. DWG files store 2D and 3D design data including geometry, layers, blocks, dimensions, text, and metadata. The format has been the backbone of the architecture, engineering, and construction (AEC) industry since the 1980s.
DWG is a proprietary format controlled by Autodesk. While several open-source libraries can read and write DWG files, full compatibility remains challenging due to the format's complexity and continuous evolution.
Core Philosophy
DWG is AutoCAD's native file format and the de facto standard for 2D and 3D CAD drawings in architecture, engineering, and construction (AEC). Unlike DXF (Autodesk's published interchange format), DWG is a proprietary binary format whose specification has never been officially published. This proprietary nature has made DWG simultaneously the most important and most contentious format in the CAD world.
The practical reality is that DWG files are everywhere in AEC and mechanical engineering workflows. Architectural firms, civil engineers, and mechanical designers exchange DWG files as their primary deliverables. Understanding DWG compatibility — which version, which features, which external references (xrefs) — is essential for anyone working in these industries, even if they do not use AutoCAD.
For interoperability, export DWG to DXF (open interchange), STEP/IGES (3D engineering), or PDF (viewing and printing). The Open Design Alliance provides open-source DWG reading libraries (LibreDWG, Open Design Alliance SDK) that enable DWG support in non-Autodesk applications, though compatibility with the latest DWG versions sometimes lags. When receiving DWG files, specify the required DWG version to avoid compatibility issues — newer versions cannot be opened by older software.
Technical Specifications
- Extension:
.dwg - MIME type:
application/acad,image/vnd.dwg - Format: Binary (proprietary)
- Magic bytes:
AC10xx(version-dependent, e.g.,AC1032for AutoCAD 2018+) - Current version: AutoCAD 2018 format (AC1032), used through AutoCAD 2025
- Coordinate precision: Double-precision floating point (64-bit)
Supported Data Types
- 2D entities: Lines, arcs, circles, polylines, splines, hatches, text, dimensions
- 3D entities: Solids, surfaces, meshes, regions
- Blocks (reusable component definitions with attributes)
- Layers with colors, linetypes, and visibility control
- Layouts (model space + paper space views)
- External references (XREFs to other DWG files)
- Tables (styles for dimensions, text, layers, linetypes)
- OLE objects, images, and attachments
- Custom objects from AutoCAD vertical products (Architecture, MEP, Civil 3D)
Version History
| Version String | AutoCAD Version | Year |
|---|---|---|
| AC1032 | 2018-2025 | 2017+ |
| AC1027 | 2013-2017 | 2012 |
| AC1024 | 2010-2012 | 2009 |
| AC1021 | 2007-2009 | 2006 |
| AC1018 | 2004-2006 | 2003 |
| AC1015 | 2000-2002 | 1999 |
How to Work With It
Opening and Viewing
# Free viewers
# - Autodesk online viewer (viewer.autodesk.com)
# - Autodesk DWG TrueView (free Windows app)
# - LibreCAD (open-source, limited DWG via libdxf)
# Open in FreeCAD (limited support)
freecad drawing.dwg
# Convert to viewable format with ODA File Converter (free)
ODAFileConverter input_dir output_dir "ACAD2018" "DXF" "0" "1"
Creating and Editing
# Python with ezdxf (DXF, convertible to DWG)
import ezdxf
doc = ezdxf.new('R2018')
msp = doc.modelspace()
msp.add_line((0, 0), (10, 0))
msp.add_circle((5, 5), radius=3)
msp.add_text('Hello', dxfattribs={'height': 0.5, 'insert': (1, 1)})
doc.saveas('drawing.dxf')
# Convert DXF to DWG with ODA File Converter or LibreDWG
# Python with LibreDWG (C library with Python bindings)
# Provides direct DWG read/write but complex API
Converting
# DWG to DXF (open format equivalent)
# Using ODA File Converter (free, cross-platform)
ODAFileConverter . ./output "ACAD2018" "DXF" "0" "1" "*.dwg"
# DWG to PDF
# AutoCAD: PLOT command or EXPORTPDF
# LibreCAD or DraftSight for free conversion
# DWG to SVG (for web)
# Via DXF intermediate: dwg2dxf then dxf2svg
# DWG to 3D formats
# Open in FreeCAD, export as STEP/STL
# Using LibreDWG tools
dwgread drawing.dwg # dump DWG contents
dwg2dxf drawing.dwg # convert to DXF
dwg2SVG drawing.dwg # convert to SVG
Programmatic Access
# Read DWG via ezdxf (reads DWG through ODA backend or converts)
# ezdxf primarily works with DXF; for DWG, convert first or use:
import ezdxf
doc = ezdxf.readfile('drawing.dxf') # DXF directly
for entity in doc.modelspace():
print(entity.dxftype(), entity.dxf.layer)
# C/C++ with Open Design Alliance (ODA) Teigha/ODA SDK
# Commercial but comprehensive DWG read/write
# C with LibreDWG (GNU project)
# Full DWG read, experimental write
Common Use Cases
- Architecture: Floor plans, building sections, construction documents
- Mechanical engineering: Part drawings, assembly drawings, manufacturing prints
- Civil engineering: Site plans, road design, utility layouts
- Electrical engineering: Schematic diagrams, panel layouts, wiring plans
- MEP (Mechanical, Electrical, Plumbing): Building systems design
- BIM coordination: 2D documentation extracted from BIM models
- GIS/Mapping: Survey and mapping data
- Facility management: As-built drawings for building maintenance
Pros & Cons
Pros
- Industry standard — virtually every AEC firm uses DWG files
- Extremely feature-rich format for 2D drafting and documentation
- Extensive ecosystem of AutoCAD-compatible software
- XREF system enables collaborative multi-file projects
- Block and attribute system for intelligent symbols and components
- Mature format with decades of backward compatibility
- Supported by hundreds of CAD applications
Cons
- Proprietary format — controlled by Autodesk, no public specification
- Full compatibility requires Autodesk software or ODA SDK (commercial)
- Open-source support (LibreDWG) is incomplete for complex files
- Large file sizes for complex drawings
- Version compatibility issues between different AutoCAD releases
- Custom objects from vertical products may not display in generic viewers
- No standardized web viewing solution
Compatibility
| Software | Read | Write | Notes |
|---|---|---|---|
| AutoCAD | Full | Full | Native format, reference implementation |
| BricsCAD | Excellent | Excellent | Best alternative, ODA-based |
| DraftSight | Good | Good | Dassault's AutoCAD alternative |
| FreeCAD | Limited | No | Via LibreDWG, basic entities only |
| LibreCAD | Limited | Limited | 2D only, via libdxf conversion |
| SketchUp | Import | No | Basic geometry import |
| Revit | Import | Export | For BIM coordination |
Programming languages: C/C++ (ODA SDK, LibreDWG, OpenDWG), Python (ezdxf for DXF, LibreDWG bindings), C# (ODA .NET), Java (ODA Java).
Key libraries:
- ODA (Open Design Alliance) — Commercial SDK, most complete DWG support
- LibreDWG — GNU GPLv3, read support mostly complete, write experimental
- ezdxf — Python, excellent DXF support (DWG via conversion)
Related Formats
- DXF — AutoCAD's open exchange format (ASCII/binary, documented)
- DWF/DWFX — Autodesk's lightweight viewing format (like PDF for CAD)
- IFC — Open BIM standard for building information modeling
- STEP — ISO standard for precise 3D geometry exchange
- SVG — Scalable Vector Graphics for web display of 2D drawings
- PDF — Universal document format, commonly used for drawing distribution
Practical Usage
- Round-tripping through DXF: When you lack native DWG tools, convert DWG to DXF for editing with ezdxf or LibreCAD, then convert back to DWG via the ODA File Converter. This is the most practical open-source workflow.
- Batch version conversion: Use ODA File Converter to batch-convert entire directories of DWG files between AutoCAD versions, which is essential when collaborating with firms using different AutoCAD releases.
- XREF management: Before sharing DWG files, use the eTransmit or Pack and Go tools to collect all external references, fonts, and plot styles into a single package. Missing XREFs are the most common issue when exchanging DWG files.
- Layer standards enforcement: Establish layer naming conventions (e.g., AIA or ISO 13567) early in a project. Use AutoCAD Layer Translator or scripted checks to enforce standards across files from multiple contributors.
- Lightweight viewing: For stakeholders who do not need to edit, convert DWG to DWF/DWFX or PDF rather than distributing the source DWG. This protects intellectual property and avoids compatibility issues.
Anti-Patterns
- Assuming open-source tools read all DWG features: LibreDWG and FreeCAD handle basic entities but will silently drop or misrender custom objects, proxy entities, and vertical product data (AutoCAD Architecture, Civil 3D). Always verify with a reference viewer.
- Sending DWG files without specifying the version: Different AutoCAD releases use different DWG versions (AC1015 through AC1032). Sending a newer DWG to a recipient with older software causes read failures. Always agree on a target version or save-down explicitly.
- Ignoring coordinate systems and units: DWG files have no enforced unit system. A drawing authored in millimeters will import at the wrong scale into a project using inches. Always check INSUNITS and confirm the coordinate system before combining files.
- Editing DWG files as generic binary: DWG is a complex structured binary format. Byte-level manipulation without a proper library will corrupt the file. Always use the ODA SDK, LibreDWG, or the DXF intermediate format for programmatic access.
- Storing DWG in version control without LFS: DWG files are large binaries that do not diff meaningfully. Committing them directly to Git bloats the repository. Use Git LFS or a dedicated document management system.
Install this skill directly: skilldb add file-formats-skills
Related Skills
DXF AutoCAD Exchange Format
The DXF file format — AutoCAD
.env
Environment variable configuration files — simple key-value files for storing application secrets and environment-specific settings, loaded at runtime.
EPS Image Format
EPS is a PostScript-based vector/raster file format historically used for print production and graphic interchange, now largely superseded by PDF and SVG but still encountered in legacy workflows.
EPUB (Electronic Publication)
The open standard ebook format maintained by the W3C, packaging XHTML content, CSS styling, images, and metadata into a single ZIP archive for reflowable digital reading.
EXE Windows Executable
The EXE file format — Windows Portable Executable (PE) format for applications, DLLs, drivers, and services, covering structure, signing, security, and analysis.
EXR Image Format
OpenEXR is a high dynamic range image format developed by Industrial Light & Magic for visual effects and CGI, supporting 16-bit and 32-bit floating-point pixels, multiple channels, and deep compositing.