AutoCAD的Dwg文件格式说明

所需积分/C币:24 2018-03-13 14:05:07 26.54MB PDF

AutoCAD的Dwg文件格式说明
OpenDwG R13/R14/R2000/R2004/R2007 File Format Specification Open DWG R13/R14/R2000/R2004/R2007 FILE Format Specification Table of contents 1 INTRODUCTION 2 BIT CODES AND DATA DEFINITIONS 1辜,1国,国 3 Rl3-RIS DWG FILE ORGANIZATION ,15 4 R2004 DWG FILE ORGANIZATION 5 R2007 DWG FILE ORGANIZATION 27 6 DWG HEADER VARIABLES .32 7 Rl3-RIS CLASS DEFINITIONS 45 8 PADDING(R13C3 AND LATER 9 IMAGE DATA(PRE-RI3C3 ……47 OBJECTS 48 11 ORIECT MAP. .coIN CO 165 12 UNKNOWN SECTION 166 13 SECOND HEADER IMAGE DATA(R13C3 AND LATER)…… …,170 15 EXTENDED ENTITY DATA (EXTENDED OBJECT DATA)......171 16 PROXY ENTITY GRAPHICS,…,,………,…,…,,……………172 OpenDWG r13/R14/R2000/R2004/R2007 File Format Specification 1 NTRODUCTION The dwG file format originated in the late 1970s, as the native format used by the first microcomputer-based computer-aided design software. In the early 1980's, that software, and the dwG file format, became the basis for AutoCAD-the best selling Cad software in history The OpenDWG file format specification, from the Open Design Alliance, is based upon Auto CAD's undocumented DwG file format. This specification includes versions frcm Release 13 up to and including R2004, and a partial description of the 2007 format. We strive to make OpenDWG as compatible with AutoCAD DWG as is possible. However, you will find in this document, certain bit and byte values listed as"unknown. "Although we invest tremendous effort reverse-engineering AutoCAD DWG. some of these values have resisted our efforts. While we are able read and write DWG files with excellent AutoCAD compatibility, we continue to work to improve our understanding of all the data in the dwG file. If you find information which will help us to understand any unknown values, or would like to get an update, to see if we have further information on these values, please contactusatouronlinesupportforumhttp:/forum.opendesign.com cu豆丁 www.docin.com OpenDwG R13/R14/R2000/R2004/R2007 File Format Specification 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 an R13/14/2000/R2004/R2007 format file 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 BB:sg会cia⊥2上: t code entmode in entities,土= instan=e} BL b BD bitdoubl BD (2 bitdou les) 3BD:3- point (3 bitdoubles) RC Inot sed) in豆丁 raw sh (not d l RD raw doubLe (not compressed) raw long (not 2RD :2 rdw doubley BRD raw doubles docin.com modular char H:hand1 e reference( see the haI式比上上C上怒 acTon) T: text tb-tshort length follovEd the string. TU Unicode text (bizshort character leng=h, followed by Unicode string, 2 bytea per caracter). Unicode -ext is read from the string strean" within the object data, see the main ohject description section for details Tv: Variable text, T for 2004 ard sarlier files, Tu for 2007+ =iles X spe S:16 byte sentinel⊥ DD BitDouble l-th Default bt: Bitrhickness BDD 3= point as eeding 3 default values Crcolor walue OpenDwG R13/R14/R2000/R2004/R2007 File Format Specification 6 A"seeker "is an RT-type object which indicates either an absolute address in the file, or an offset from some known address A sentinel"is 16 byles of data used for file recovery purposes aIly, the compressed forms are used to allow for compression of common data, usually vahles 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 examples of how they appear in Che file 2.1 BITSHORT 12 bits what it is 00 A short (2 bytes follows, little-endiar order (LsB first) 01: A unsigned char (1 byte] fcl=WS 11 The char size is used when positive shorts less than 256 are heing stored. The short size is used when values <O or >=256 are being stored. Obviously the special cases for O and 256 are used when those values are being stored Negative numbers use the short form, not the char form. That is, -l is 00. 11111111.11111111, not 01,11111111 For instance, if we were known to be reading 5 shorts from the following stream ufbils 0000C003010000003110110_0000111110 it would be parsed like this 000C0000100003001 short257) 010C001111 22 BITLONG: 12 bits i what it is 00 A long (4 Eutes) follows, little-endian order (LsB first) 01: A unsigned char (1 byte) follows 11 nct used OpenDwG R13/R14/R2000/R2004/R2007 File Format Specification or >-256 are being stored. Obviously the special case for 0 is used when storing e is used when values <0 The char size is used when positive longs less than 256 are heing stored. The long si Negalive numbers use the short forIn, Il the char furIn. Thal is,-1 is 00.11111111.11-11111.11-11-11.11111111;not01.11111111 For instance, if we were known to be reading 5 longs from the following stream of bits 000c00301000000100000000000000010010000111110 it would be parsed like this: 000c00-0010000300100000000000c0000(1。rg257 010c001111 5) 10 0) 2.3 BITDOUBLE. 1st 2 bits what it 0o :A double flow n豆丁 01 1.0 11: not sed Doubles are eight byte IEEE woodiN. com 2.4 MODULAR CHARS: Modular characters are a method of storing compressed integer values. They are used in the object map to indicate both handle offsets and file location offsets. They consist of a stream of bytes, terminating when the high bit of the byte is 0 In each byte, the high bit is a flag: when set, it indicates that another byte follows. The concept is not difficult Lo understand, but is a little difficult lo explain. Let's look at an example Assume the next two bytes in the file are 100C01300-0003 1)We read bytes until we reach a byte with a high bit of 0. Obviously the second byte meets that criterion Since we are reading from least significant to most significant, let's reverse the order of the bytes so that they read mSB to LSB from left to right. OpenDwG R13/R14/R2000/R2004/R2007 File Format Specification 8 110000010001001oo Least significant Bvte Mos significant Byta 000 0 Most Significant Byte Least Signifi cant Byle 2) Now we drop the high order flag bits 00100100 U0000 Most significant Byt Least significant Byt lo00001|0 3)And then rc-group thc bits from right to lcft, padding on the left with 0's 00 00 00000 丁 oo|o1001|||0|o|0 00a10 Result=2+18*250=4610 Here' s another example using the basic form F1101001 F0012-11 F110011 2 00110101 1110100110910-111115010n11151 1)We read bytes until we reach a byte with a high bit of0. Obviously the fourth byte meets that criterion Since we are reading from least significant to most significant, let's reverse the order of the bytes so that hey read MSB to LSB from left to right 01 0010111 1 0|0 eas significant Byte Most significant Byte 3 2 3 4 Johi1olb11111o1o1oo1o11-11110oo Moet significant Byte Least signiti cant Byte 2) Now we drop the high order flag bits: OpenDWG r13/R14/R2000/R2004/R2007 File Format Specification 9 111001101001011 o100 00 0 o1|0|111010|0 3)And then re-group the bits from right to left, padding on the left with Os 01 0D 011 1101001 110 1|oo|o1a|11 Resu:233+139*256+185*256^2+6*256^3=112823273 This process is further curnplicaled by the fact that if Lhe linal byle (high bit O)also has Lhe 64 bit(0x40)seL, this means to negate the number. This is a negative number: 10000101 01001011 1) Since we are reading fron least signilicanL Lo must signilicant, let's reverse the urder uf the byles so that they read MSB to LSB from left to right 1000010 001011 ast significant Byte Mos significant Byte www.ae.com ooloollolooolol Most Significant Byte Least Significant Byte We then clear the bit that was used to represent the negative mumber, and note that the result must b 000 0|11 10000|1c1 Set to o e drop the high order flag bits 1000010 OpenDwG R13/R14/R2000/R2004/R2007 File Format Specification 10 4)And then re-group the bits from right to left, padding on the left with O, s 00010 000010 00000 011000010 Result: 133+5 256=1413, which we negate to get-1413 Modular chars are also used to store handle offsets in the object map In this case there is no negation used handles in the object map are always in increasing order. 25 MODULAR SHORTS Modular shorts work just like modular chars --except that the base module is a short instead of a char There are only two cases to worry about here(from a practical point of view), because, in the case of shorts, wo modules make a long, and since these are used only to indicate object sizes, a maximum object size of 1 GB is probably correct 0011C00111:1003100011010000000 1)Reverse the order of the shorts 10|C Mast Significant Byte Leas Significant Byte Most Significant eyte Least Sig ifl ant Byte 100|0 010000000c 0c0 110100 MEst signifi cant Byte Leas significant Byte Most significant Eyt Least signif sant Byte 2) Reverse the order of the bytes in each short: 10001 n10000a0nc 060 MEst significant yte Leas signif cant Byte Most sIgnificant Eye Least signifiant Byte oo|ooo|ooL1|o0|o|11|1」L1|4|o1o。」Loo|1|1loo1」 l户 ast significant Fyte Mns significant Byte I east sigrificant Byte ficant Rvle 3) Drop the high order flag bit of each short 0000c00 0 11101000011000

...展开详情
img
myytsm

关注 私信 TA的资源

上传资源赚积分,得勋章
最新资源