Open Design Specification for .Dwg Files Version 5.4.1 Open Design Alliance
Total Page:16
File Type:pdf, Size:1020Kb
Open Design Specification for .dwg files Version 5.4.1 Open Design Alliance www.opendesign.com Copyright © 1998-2018 Open Design Alliance, Inc. All rights reserved. Information in these materials is furnished for informational use only, is subject to change without notice and does not represent a commitment on the part of Open Design Alliance. Open Design Alliance assumes no responsibility or liability for any errors or inaccuracies that may appear in these materials. Use these materials at your own risk. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, OPEN DESIGN ALLIANCE AND ITS SUPPLIERS DISCLAIM ANY AND ALL WARRANTIES AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, AND THOSE ARISING OUT OF USAGE OF TRADE OR COURSE OF DEALING, CONCERNING THESE MATERIALS. THESE MATERIALS ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL OPEN DESIGN ALLIANCE OR ITS SUPPLIERS (OR THEIR RESPECTIVE AGENTS, DIRECTORS, EMPLOYEES OR REPRESENTATIVES) BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, CONSEQUENTIAL, INCIDENTAL, DIRECT, INDIRECT, SPECIAL, ECONOMIC, PUNITIVE OR SIMILAR DAMAGES, OR DAMAGES FOR LOSS OF BUSINESS PROFITS, LOSS OF GOODWILL, BUSINESS INTERRUPTION, COMPUTER FAILURE OR MALFUNCTION, LOSS OF BUSINESS INFORMATION OR ANY AND ALL OTHER COMMERCIAL OR PECUNIARY DAMAGES OR LOSSES) ARISING OUT OF THE USE OF THESE MATERIALS, HOWEVER CAUSED AND ON ANY LEGAL THEORY OF LIABILITY (WHETHER IN TORT, CONTRACT OR OTHERWISE), EVEN IF OPEN DESIGN ALLIANCE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. Because some jurisdictions do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you. Teigha® is a trademark of Open Design Alliance in the United States and/or other countries. All other trademarks, trade names or company names referenced herein are used for identification only and are the property of their respective owners. US Government Restricted Rights: These materials are provided with RESTRICTED RIGHTS. Use, duplication or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of The Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 or subparagraphs (c)(1) and (2) of the Commercial Computer Software-Restricted Rights at 48 CFR 52.227-19, as applicable. The contractor/manufacturer is Open Design Alliance, 5025 N Central Ave #602, Phoenix, AZ, USA. Printed in USA. * DWG is the native and proprietary file format for AutoCAD® and a trademark of Autodesk, Inc. The Open Design Alliance is not associated with Autodesk. Open Design Specification for .dwg files 4 Open Design Specification for .dwg files Table of Contents 1 Introduction ......................................................................................................................... 6 2 BIT CODES AND DATA DEFINITIONS........................................................................... 7 3 R13-R15 DWG FILE FORMAT ORGANIZATION .......................................................... 20 4 R2004 DWG FILE FORMAT ORGANIZATION .............................................................. 23 5 R2007 DWG FILE FORMAT ORGANIZATION .............................................................. 36 6 R2010 DWG FILE FORMAT ORGANIZATION .............................................................. 69 7 R2013 DWG FILE FORMAT ORGANIZATION .............................................................. 70 8 R2018 DWG FILE FORMAT ORGANIZATION .............................................................. 71 9 Data section AcDb:Header (HEADER VARIABLES) ....................................................... 72 10 Data section AcDb:Classes ............................................................................................ 86 11 PADDING (R13C3 AND LATER) ................................................................................ 89 12 Data section: “” .............................................................................................................. 90 13 Data section AcDb:SummaryInfo Section ...................................................................... 91 14 Data section AcDb:Preview ........................................................................................... 93 15 Data section AcDb:VBAProject Section ......................................................................... 95 16 Data section AcDb:AppInfo ........................................................................................... 96 17 Data section AcDb:FileDepList ...................................................................................... 98 18 Data section AcDb:RevHistory .................................................................................... 100 19 Data section AcDb:Security ......................................................................................... 101 20 Data section AcDb:AcDbObjects ................................................................................. 103 21 Data section AcDb:ObjFreeSpace ................................................................................ 249 Open Design Specification for .dwg files 5 22 Data section: AcDb:Template ....................................................................................... 250 23 Data section AcDb:Handles (OBJECT MAP) .............................................................. 251 24 Section AcDb:AcDsPrototype_1b (DataStorage) .......................................................... 252 25 UNKNOWN SECTION ............................................................................................... 263 26 SECOND FILE HEADER (R13-R15) ......................................................................... 264 27 Data section: AcDb:AuxHeader (Auxiliary file header) ................................................ 267 28 Extended Entity Data (Extended Object Data) ....................................................... 269 29 PROXY ENTITY GRAPHICS .................................................................................... 270 Open Design Specification for .dwg files 6 1 Introduction Originating in the late 1970s, drawing files created with microcomputer-based computer-aided design software were saved with the .dwg extension. In the early 1980s, Autodesk® released AutoCAD® which eventually became the most used CAD software in the world and which used Autodesk’s undocumented and proprietary DWG™ file format (using the .dwg extension). The Open Design Specification for .dwg files serves AutoCAD’s undocumented and proprietary DWG file format. This specification includes DWG file format versions 13 up to and including version 2013. Further, the Open Design Specification for .dwg files serves the Teigha® software development platform of the Open Design Alliance. While our Open Design Specification for .dwg files is able to read and write .dwg files with excellent AutoCAD compatibility, we continue to work to improve our understanding of all the data in a .dwg file. If you find information which will help us to understand any unknown values, please contact us at http://www.opendesign.com/contact. Open Design Specification for .dwg files 7 2 BIT CODES AND DATA DEFINITIONS NOTE: Unless otherwise stated, all data in this manual is in little-endian order, with the least significant byte first. Much of the data in the DWG file format versions 13/14/2000/2004/2007/2010 must be read at the bit level. Various parts of the drawing use data in compressed forms, which are explained below. Here are the abbreviations used in this document for the various compressed forms: B : bit (1 or 0) BB : special 2 bit code (entmode in entities, for instance) 3B : bit triplet (1-3 bits) (R24) BS : bitshort (16 bits) BL : bitlong (32 bits) BLL : bitlonglong (64 bits) (R24) BD : bitdouble 2BD : 2D point (2 bitdoubles) 3BD : 3D point (3 bitdoubles) RC : raw char (not compressed) RS : raw short (not compressed) RD : raw double (not compressed) RL : raw long (not compressed) 2RD : 2 raw doubles 3RD : 3 raw doubles MC : modular char MS : modular short H : handle reference (see the HANDLE REFERENCES section) T : text (bitshort length, followed by the string). TU : Unicode text (bitshort character length, followed by Unicode string, 2 bytes per character). Unicode text is read from the “string stream” within the object data, see the main Object description section for details. TV : Variable text, T for 2004 and earlier files, TU for 2007+ files. X : special form U : unknown SN : 16 byte sentinel BE : BitExtrusion DD : BitDouble With Default BT : BitThickness 3DD : 3D point as 3 DD, needing 3 default values Open Design Specification for .dwg files 8 CMC : CmColor value TC : True Color: this is the same format as CMC in R2004+. OT : Object type A “seeker” is an RL-type object which indicates either an absolute address in the file or an offset from some known address. A “sentinel” is 16 bytes of data used for file recovery purposes. Generally, the compressed forms are used to allow for compression of common data, usually values like 0.0 and 1.0 for doubles, 0 and 256 for shorts. The method for interpreting the code is to read the first two bits, which indicate either the size of the data to follow, or the actual value for the common values. Here are the compressed formats and some