DWG文件的设计规范 V4.5.1(中英对照版)
DWG文件的设计规范 V4.5.1
Open Design Specification for .dwg files
Version 5.4.1
liability英[ˌlaɪəˈbɪləti] 美[ˌlaɪəˈbɪləti]n. 责任;倾向;债务;妨碍
assumesv. 取得(权力)( assume的第三人称单数 );假设;假定;呈现
is subject to英[iz ˈsʌbdʒikt tu:] 美[ɪz ˈsʌbdʒekt tu]受支配,从属于;有…倾向的
furnished英[ˈfɜːnɪʃt] 美[ˈfɜːrnɪʃt]adj. 家具,有家具的v. 陈设,布置( furnish的过去式和过去分词);提供,装备
commitment英[kəˈmɪtmənt] 美[kəˈmɪtmənt]n. 信奉,忠诚;承诺;已许诺的事;献身;投入;花费
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. 这些材料仅仅用于获取信息,如有更改恕不通知,并不代表ODA的承诺;ODA不为材料中的错误或者不准确的说法承担任何责任;使用这些材料,风险自负;
permittedv. 允许( permit的过去式和过去分词 );许可;许用adj. . 被允许的
disclaim英[dɪsˈkleɪm] 美[dɪsˈkleɪm]vt. 否认
either英[ˈaɪðə(r)] 美[ˈiː.ðər]pron. (两者之中)任意一个;两者都(不)adv. 也(不);而且,还
express英[ɪkˈspres] 美[ɪkˈspres]v. 表达,表示;不言自明;挤出;快递adj. 明确的;特快的;用快递寄送的
implied英[ɪm'plaɪd] 美[ɪm'plaɪd]adj. 暗指的,含蓄的v. 暗示,暗指( imply的过去式和过去分词 );必然包含;说明,表明
merchantability英[ˌmɜ:tʃəntə'bɪlɪtɪ] 美[ˌmɜtʃəntə'bɪlɪtɪ][经] 有销路,可销售
infringement英[ɪn'frɪndʒmənt] 美[ɪnˈfrɪndʒmənt]n. 侵权;违反;违背
arisingv. 呈现,出现,发生( arise的现在分词 );(由…)引起;起身
dealing英[ˈdiːlɪŋ] 美[ ˈdiːlɪŋ]n. (商业)活动;经营方式;交易v. 经营,买卖; 贩毒
concerning英[kənˈsɜːnɪŋ] 美[kənˈsɜːrnɪŋ]prep. 关于,涉及adj. 令人担忧的v. 与…相关;
warranty英[ˈwɒrənti] 美[ˈwɔːrənti]n. 保证,保修单
applicable英[əˈplɪkəbl , ˈæplɪkəbl] 美[ˈæplɪkəbl , əˈplɪkəbl]adj. 适当的;可应用的;适用的
ANY AND ALL任何和所有;
INCLUDING,WITHOUT LIMITATION 包括但不限于;
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. 在法律许可的最大范围内,ODA否认任何和所有保证和条件,无论是隐式的还是显式的;包括但不局限于以下情况:对于这些材料的 可销售性、特殊用途的适用性、没有侵权、将这些材料其用于商业和贸易可能引发的后果;这些材料都是原样提供的,并且没有任何的保证;
whatsoever英[ˌwɒtsəʊ'evə(r)] 美[ˌhwɑtsoʊ'evər]adv. 丝毫,任何
incidental英[ˌɪnsɪˈdentl] 美[ˌɪnsɪˈdɛntl]adj. 附属的;易发生的,偶然发生的;伴随发生的
however英[haʊˈevə(r)] 美[haʊˈevər]adv. 然而;不管怎样;…左右conj. 不管怎样
whether英[ˈweðə(r)] 美[ˈweðər]conj. (表示选择或怀疑)是否;无论,不管
tort英[tɔ:t] 美[tɔrt]n. 民事侵权行为
claim英[kleɪm] 美[kleɪm]v. 声称;索取;赢得;需要;夺去(生命)n. 声称,主张;权利;索赔
jurisdictionsn. 司法权( jurisdiction的名词复数 );裁判权;管辖区域;管辖范围
consequential英[ˌkɒnsɪˈkwenʃl] 美[ˌkɑnsəˈkwenʃl]adj. 作为结果的,间接的;重要的
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.
herein英[ˌhɪərˈɪn] 美[ˌhɪrˈɪn]adv. 此中,本文中,于此;焉
identification英[aɪˌdentɪfɪˈkeɪʃn] 美[aɪˌdentɪfɪˈkeɪʃn]n. 识别;身份证明;密切关联;认同;同情
respective英[rɪˈspektɪv] 美[rɪˈspektɪv]adj. 各自的,分别的
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. Teigha是ODA在美国和/或其他国家使用的商标;本文中引用的 其他的商标、商品名称公司名称 仅仅用于标识,他们都是各自所有者的财产;
restricted英[rɪˈstrɪktɪd] 美[rɪˈstrɪktɪd]adj. 有受限制的;(土地)对公众不完全开放的;保密的
disclosure英[dɪsˈkləʊʒə(r)] 美[dɪsˈkloʊʒə(r)]n. 公开;泄露,揭露
set forth英[set fɔ:θ] 美[sɛt fɔrθ]起程;出发;详尽地解释;展示
applicable英[əˈplɪkəbl , ˈæplɪkəbl] 美[ˈæplɪkəbl , əˈplɪkəbl]adj. 适当的;可应用的;适用的
is subject to restrictions 受到限制;
contractor英[kənˈtræktə(r)] 美[ˈkɑnˌtræktɚ, kənˈtræk-]n. 订约人;承包商
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. 美国政府的有限权利,这些材料具有有限权利;政府使用、复制或者披露这些材料都要受到限制,如下面条款所展示的那样:技术数据和电脑软件条款、商业电脑软件有限权利,都适用;承包商、制造商是ODA;
proprietary英[prəˈpraɪətri] 美[prəˈpraɪəteri]adj. 专有的,专利的;所有(人)的;(商品)专卖的
native 原生的,本地的;
* 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. dwg是欧特克公司的原生格式,并且拥有专利权;ODA和欧特克公司没有任何关系;
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 数据部分-VBA
16 Data section AcDb:AppInfo...........................................................................................96 数据部分-APP信息
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 实体图形代理
1 Introduction 简介
originating英[ə'rɪdʒɪneɪtɪŋ] 美[ə'rɪdʒɪneɪtɪŋ]v. 起源于,来自,产生( originate的现在分词 );创造;创始;开创
undocumented英[ˌʌn'dɒkjʊmentɪd] 美[ˌʌn'dɑkjʊmentɪd]adj. 无正式文件的,无事实证明的
proprietary英[prəˈpraɪətri] 美[prəˈpraɪəteri]adj. 专有的,专利的;所有(人)的;(商品)专卖的
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).
早在70年代,DWG就作为计算机绘图和辅助设计软件的保存文件后缀;在80年代,Autodesk发布了CAD这个全世界使用最广泛的软件,CAD使用了这个没有文件证明并且专有的DWG文件格式;
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.
DWG的公开设计规范用于CAD文件格式;设计规范包括版本13和2013;另外,DWG文件设计规范也用于ODA的Teigha开发平台;
compatibility英[kəmˌpætəˈbɪləti] 美[kəmˌpætəˈbɪlətɪ]n. 并存,相容;兼容性
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.
DWG的公开设计规范能够读写DWG文件,并且兼容CAD;我们将继续深入理解DWG文件数据;如果你发现了什么有价值的信息,请联系我们;
2 BIT CODES AND DATA DEFINITIONS位编码和数据定义
otherwise英[ˈʌðəwaɪz] 美[ˈʌðərwaɪz]adv. 否则;除此以外;与之不同地;以其他方式
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) 1-3个比特位
BS : bitshort (16 bits) 16位
BL : bitlong (32 bits) 32位
BLL : bitlonglong (64 bits) (R24) 64位
BD : bitdouble 浮点型
2BD : 2D point (2 bitdoubles) 2个浮点型
3BD : 3D point (3 bitdoubles) 3个浮点型
RC : raw char (not compressed) 字符 未压缩
RS : raw short (not compressed) 16位 未压缩
RD : raw double (not compressed) 浮点型 未压缩
RL : raw long (not compressed) 长整型 未压缩
2RD : 2 raw doubles 2个浮点型
3RD : 3 raw doubles 3个浮点型
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; Unicode文本
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 16字节序列号;
BE : BitExtrusion 位挤出?
DD : BitDouble With Default 默认浮点型16字节
BT : BitThickness 位厚度?
3DD : 3D point as 3 DD, needing 3 default values 3D点,有三个默认值;
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.搜索器可以表明一个绝对地址或者一个相对于已知地址的偏移量;
sentinel英[ˈsentɪnl] 美[ˈsɛntənəl]n. 岗哨,哨兵vt. . 守卫,放哨
recovery英[rɪˈkʌvəri] 美[rɪˈkʌvəri]n. 恢复;改善;失而复得;
A “sentinel” is 16 bytes of data used for file recovery purposes.
“哨兵”有16个字节,用来恢复文件;
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 examples of how they appear in the file:
通常,压缩表格用来压缩数据;压缩数据的解析方法是,先读取前2位,这2位表明数据的长度,或者就是数据本身的值;下面是压缩数据的格式,以及他们如何在文件中呈现的例子:
2.2 BITSHORT:短整形(16位)
1st 2 bits : what it is 数据前两位的含义
00 : A short (2 bytes) follows, little-endian order (LSB first) 00表示这是一个短整形数据,2字节;
01 : An unsigned char (1 byte) follows;01表示这是一个字符型数据,1字节;
10 : 0 ;10表示0
11 : 256 ;11表示256
The char size is used when positive shorts less than 256 are being stored. The short size is used when
values <0 or >=256 are being stored. Obviously the special cases for 0 and 256 are used when those
values are being stored.
小于256的正短整形(2字节)将用一个字节存储;当值小于0或者大于256时,用短整型存储(2字节);
特殊的两个值是0和256
Negative numbers use the short form, not the char form. That is, -1 is 00.11111111.11111111, not
01.11111111.负数用短整型而不是字节型;
For instance, if we were known to be reading 5 shorts from the following stream of bits:
0000000001000000011011010000111110
It would be parsed like this:这一串bit可以解析成:
00 00000001 00000001 (short 257)
10 (0)
11 (256)
01 00001111 (15)
10 (0)
2.3 BITLONG:
1st 2 bits : what it is
00 : A long (4 bytes) follows, little-endian order (LSB first) 长整形,4字节;
01 : An unsigned char (1 byte) follows 无符号字节,1字节;
10 : 0
11 : not used
The char size is used when positive longs less than 256 are being stored. The long size is used when
values <0 or >=256 are being stored. Obviously the special case for 0 is used when storing 0.
小于256的正整数用1字节表示;long适用于负数和超过255的数;
Negative numbers use the short form, not the char form. That is, -1 is 负数用4字节表示,而不是1字节;
00.11111111.11111111.11111111.11111111, not 01.11111111.
For instance, if we were known to be reading 5 longs from the following stream of bits:
000000000100000001000000000000000010010000111110
It would be parsed like this:
00 00000001 00000001 00000000 00000000 (long 257) 不是257吧??
10 (0)
01 00001111 (15)
10 (0)
2.4 BITLONGLONG(64位 8字节)
The first 1-3 bits indicate the length l (see paragraph 2.1). Then l bytes follow, which represent the
number (the least significant byte is first).
前3位表示数据长度,后面的对应位数才是数据值;
2.5 BITDOUBLE:浮点型()
1st 2 bits : what it is
00 : A double follows
01 : 1.0
10 : 0.0
11 : not used
Doubles are eight byte IEEE standard floating point values.
IEEE 标准中,double是8字节;
2.6 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.
模字符用来存储整形数据;他被用来表示句柄偏移和文件位置偏移;他由字节流组成,当遇到最高位为0的字节时,表示该字节流的结束;
In each byte, the high bit is a flag; when set, it indicates that another byte follows. The concept is not
difficult to understand, but is a little difficult to explain. Let’s look at an example.
在每个字节中,最高位都是标志位;当最高位置1时,表示后面还有字节;这个概念不难理解,但是难于解释,看个例子;
Assume the next two bytes in the file are:
10000010 00100100
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.
我们读取字节,直到遇到一个高位(标志位)是0的字节;显然,第二个字节就是结束标志;
MSB:Most Significant Bit(最高有效位),也就是最高位,最左侧的bit。
LSB:Least Significant Bit(最低有效位),最低位,最右侧的bit。
2.8 Bit Extrusion 位挤出
For R13-R14 this is 3BD. For R2000, this is a single bit, followed optionally by 3BD. If the single bit is
1, the extrusion value is assumed to be 0,0,1 and no explicit extrusion is stored. If the single bit is 0, then
it will be followed by 3BD.单独的1位如果是1,表示0,0,1;如果是0表示后面有一个3BD类型数据,3个浮点型,表示3D点数据;
2.9 BitDouble With Default 有默认值的浮点型
opcode英[ˈɒpkəʊd] 美[ˈɑpkoʊd]n. 操作码
This is a 2 bit opcode followed optionally by data, and it requires a default value. The different opcodes
are described as follows:
2位的操作码,后面可能有数据,他需要有一个默认值;
00 No more data present, use the value of the default double.
00表示后面没有数据,使用double的默认值;
patched英['pætʃt] 美['pætʃt]v. 补( patch的过去式和过去分词 );修理;调停;解决
01 4 bytes of data are present. The result is the default double, with the 4 data bytes patched in
replacing the first 4 bytes of the default double (assuming little endian).
01表示后面有4字节的数据;结果是double的默认值,用4字节数据代替4字节默认值;
10 6 bytes of data are present. The result is the default double, with the first 2 data bytes patched in
replacing bytes 5 and 6 of the default double, and the last 4 data bytes patched in replacing the first 4
bytes of the default double (assuming little endian).
10表示后面有6字节数据;结果是double默认值用前2个字节数据替代第5和6字节的默认值;最后4字节代替前面4字节默认值;
11 A full RD follows.
2.10BitThickness 厚度位
For R13-R14, this is a BD. For R2000+, this is a single bit followed optionally by a BD. If the bit is one,
the thickness value is assumed to be 0.0. If the bit is 0, then a BD that represents the thickness follows.
BD : bitdouble 浮点型;对于R2000+版本,这一位后面就是一个浮点数;如果这一位是1,厚度值就是0.0,;如果这一位是0,后面就是一个浮点数;
2.11CmColor
R15 and earlier: BS color index 2字节颜色索引;
R2004+: There are two types of color definitions, below named as CMC and ENC:
CMC:
BS : color index (always 0) 两字节
BL : RGB value 四字节
RC : Color Byte (& 1 => color name follows (TV), 字符 1字节;
&2 => book name follows (TV))
ENC: This color is used by entities: this definition may contain a DBCOLOR reference and optional
transparency.
BS : color number: flags + color index
color flags: first byte of the bitshort.
0x8000: complex color (rgb).
Next value is a BS containing the RGB value (last 24 bits).
0x4000: has AcDbColor reference (0x8000 is also set in this case).
The handle to the color is written in the handle stream.
0x2000: color is followed by a transparency BL.
The first byte represents the transparency type:
0 = BYLAYER,
1 = BYBLOCK,
3 = the transparency value in the last byte.
Color index: if no flags were set, the color is looked up by the color number (ACI
color)
2.12Object type 对象类型
Until R2007, the object type was a bit short. In R2010 the object type changed:
A bit pair, followed by either 1 or 2 bytes, depending on the bit pair value:
2007版本中,用2字节表示;2010版本中用2位表示,后面跟1字节或2字节;
Bit pair value |
How to interpret following 1-2 bytes 如何解析后面的1-2个字节 |
0 |
Read the following byte 读取后面1字节; |
1 |
Read following byte and add 0x1f0. 读取1字节并加上0x1f0; |
2 |
Read the following two bytes (raw short) 读取2字节; |
3 |
The value 3 should never occur, but interpret the same as 2 nevertheless. 3永远不会出现,不过解释方法同2; |
nevertheless英[ˌnevəðəˈles] 美[ˌnevərðəˈles]adv. 然而;尽管如此;不过
2.13HANDLE REFERENCES: 句柄引用
referred英[rɪˈfɜːd] 美[rɪˈfɜːrd]vi. (to)涉及,查阅v. 提到( refer的过去式和过去分词 );针对;关系到;请教
All objects in R13+ .dwg files are referred to by object handles. These handles are stored in the file in the
following form:
R13+版本涉及到了对象句柄;按照如下格式存储:
|CODE (4 bits)|COUNTER (4 bits)|HANDLE or OFFSET|
In this document we write these as CODE.COUNTER.BYTE.BYTE..., such as 0101.0001.00001111 (the
usual reference to LAYER 0 for drawings created under R13, which has handle F). In abbreviated form,
we write 5.1.0F.
abbreviated英[ə'bri:vɪeɪtɪd] 美[ə'brivɪeɪtɪd]adj. 简短的,仅可蔽体的,小型的v. 缩简;缩略;使用缩写词
form英[fɔːm] 美[fɔːrm]n. 类型;形态,外形;表格;状态v. 形成,构成;组建,排列
4位编码,4位长度(字节数),后跟句柄或者偏移量;R13以下版本,LAYER 0的句柄是F;缩写形态就是5.1.0F;
The CODE has different meanings depending on the handle. Certain object handles in AutoCAD have
"ownership" relations with other objects. In these cases the code indicates the type of relation:
编码表示句柄类型;CAD中的对象句柄和其他对象有隶属关系;编码就表示关系类型,如下表:
Code |
Desciption |
2 |
Soft ownership reference: the owner does not need the owned object. The owned object cannot exist by itself.软拥有,主人不拥有对象,该对象可以独自存在; |
3 |
Hard ownership reference: the owner needs the owned object. The owned object cannot exist by itself.硬拥有:主人拥有对象,该对象不能独自存在; |
4 |
Soft pointer reference: the referencing object does not need the referenced object and vice versa.软指针,引用者不需要被引用对象,而是相反; |
5 |
Hard pointer reference: the referencing object needs the referenced object, but both are owned by another object.硬指针,引用者需要被引用对象,并且二者同时被第三者所拥有; |
We will call these TYPEDOBJHANDLEs. Often their type is fixed to some value at all times; in other
words, for instance in a certain position only a HARD_POINTER TYPEDOBJHANDLE would be
allowed.
这称为类型对象句柄;通常他们的类型是固定的;也就是说,只能使用硬指针引用;
In other cases, the handle is stored as an offset from some other handle, and the code indicates how the
offset is to be applied. These handles always represent a soft pointer reference. See the table below for the
codes and their meaning:
通常,句柄存储的是相对于其他句柄的偏移量,编码表示如何使用偏移量;这些句柄是软指针引用;如下表:
Code: Action:
0x2, 0x3, 0x4, 0x5 none - just read offset and use it as the result 读取偏移量
0x6 result is reference handle + 1 (length is 0 in this case)句柄偏移1,长度 0
0x8 result is reference handle – 1 (length is 0 in this case)句柄偏移-1 长度0
0xA result is reference handle plus offset 正偏移量
0xC result is reference handle minus offset 负偏移量
We will call these OFFSETOBJHANDLEs. These handles are described with (CODE X), where X
indicates the code if the offset is an ABSOLUTE reference (0x2 – 0x5).
这称为偏移句柄;这些句柄在4位code后面跟1位X,表示是否是绝对引用;
COUNTER tells how many bytes of HANDLE follow.
EXAMPLE: An entity on a layer whose handle is 5E7 has the following handle reference near the end of
the entity data (its code being 5):
5 2 0 5 E 7
01010010 00000101 11100111 (0101.0010.00000101.11100111)
2.14CRCS:
2.14.1 8-bit CRC 循环冗余校验
modification英[ˌmɒdɪfɪˈkeɪʃn] 美[ˌmɑːdɪfɪˈkeɪʃn]n. 修改,修正,变更,改良,改进
redundancy英[rɪˈdʌndənsi] 美[rɪˈdʌndənsi]n. 过多,过剩;冗长;裁员;(机器的)多余度
CAD使用修正的循环冗余校验,作为检错机制;CRC(循环冗余校验)以2字节结尾,因为表格中包含256个16位值,他们不以任何类型的位的形式存储;他们以字节存储;他们不嵌入位编码;因此在一个对象末尾可能有未被使用的位(闲置位);例子如下:
The AutoCAD DWG file format uses a modification of a standard cyclic redundancy check as an error
detecting mechanism. The CRC ends up being 2 bytes long due to a lookup in a table containing 256 16-
bit values, and are not stored in any sort of bit code form. They also always appear on byte boundaries;
they are not embedded within the stream of bits. Thus there may be extra unused bits at the end of an
object. For instance, consider an object containing one bitshort, as follows:
01000000 11100000 01010101 01010101
This parses as:
01 bitshort with one character
00000011 the value of the bitshort (3)
100000 unused bits 闲置位
01010101 01010101 the CRC 校验位
whereby英[weəˈbaɪ] 美[werˈbaɪ]adv. 凭此;借以
beyond英[bɪˈjɒnd] 美[bɪˈjɑːnd]prep. 在…另一边;超过,超出;晚于;无法理解
The modification that is made to the CRC is that a starting value different from 0 is used. Autodesk also
uses a method whereby the result of the CRC is XORed with a "magic number". This method is used
extensively in pre-R13 files, but seems only to be used in the header for R13 and beyond.
Here is the CRC function we use; it is simply a standard 8 bit CRC calculation:
对CRC的修订是,使用一个不以0开头的数;CRC的结果是和一个魔法数进行异或运算;R13之前版本一般都用这个方法,R13及之后的版本仅仅在头部校验使用该方法;下面是CRC函数,是一个标准的8位CRC算法:
int crctable[256]= { 0x0000,0xC0C1,0xC181,0x0140,0xC301,0x03C0,0x0280,0xC241,
0xC601,0x06C0,0x0780,0xC741,0x0500,0xC5C1,0xC481,0x0440,
0xCC01,0x0CC0,0x0D80,0xCD41,0x0F00,0xCFC1,0xCE81,0x0E40,
0x0A00,0xCAC1,0xCB81,0x0B40,0xC901,0x09C0,0x0880,0xC841,
0xD801,0x18C0,0x1980,0xD941,0x1B00,0xDBC1,0xDA81,0x1A40,
0x1E00,0xDEC1,0xDF81,0x1F40,0xDD01,0x1DC0,0x1C80,0xDC41,
0x1400,0xD4C1,0xD581,0x1540,0xD701,0x17C0,0x1680,0xD641,
0xD201,0x12C0,0x1380,0xD341,0x1100,0xD1C1,0xD081,0x1040,
0xF001,0x30C0,0x3180,0xF141,0x3300,0xF3C1,0xF281,0x3240,
0x3600,0xF6C1,0xF781,0x3740,0xF501,0x35C0,0x3480,0xF441,
0x3C00,0xFCC1,0xFD81,0x3D40,0xFF01,0x3FC0,0x3E80,0xFE41,
0xFA01,0x3AC0,0x3B80,0xFB41,0x3900,0xF9C1,0xF881,0x3840,
0x2800,0xE8C1,0xE981,0x2940,0xEB01,0x2BC0,0x2A80,0xEA41,
0xEE01,0x2EC0,0x2F80,0xEF41,0x2D00,0xEDC1,0xEC81,0x2C40,
0xE401,0x24C0,0x2580,0xE541,0x2700,0xE7C1,0xE681,0x2640,
0x2200,0xE2C1,0xE381,0x2340,0xE101,0x21C0,0x2080,0xE041,
0xA001,0x60C0,0x6180,0xA141,0x6300,0xA3C1,0xA281,0x6240,
0x6600,0xA6C1,0xA781,0x6740,0xA501,0x65C0,0x6480,0xA441,
0x6C00,0xACC1,0xAD81,0x6D40,0xAF01,0x6FC0,0x6E80,0xAE41,
0xAA01,0x6AC0,0x6B80,0xAB41,0x6900,0xA9C1,0xA881,0x6840,
0x7800,0xB8C1,0xB981,0x7940,0xBB01,0x7BC0,0x7A80,0xBA41,
0xBE01,0x7EC0,0x7F80,0xBF41,0x7D00,0xBDC1,0xBC81,0x7C40,
0xB401,0x74C0,0x7580,0xB541,0x7700,0xB7C1,0xB681,0x7640,
0x7200,0xB2C1,0xB381,0x7340,0xB101,0x71C0,0x7080,0xB041,
0x5000,0x90C1,0x9181,0x5140,0x9301,0x53C0,0x5280,0x9241,
0x9601,0x56C0,0x5780,0x9741,0x5500,0x95C1,0x9481,0x5440,
0x9C01,0x5CC0,0x5D80,0x9D41,0x5F00,0x9FC1,0x9E81,0x5E40,
0x5A00,0x9AC1,0x9B81,0x5B40,0x9901,0x59C0,0x5880,0x9841,
0x8801,0x48C0,0x4980,0x8941,0x4B00,0x8BC1,0x8A81,0x4A40,
0x4E00,0x8EC1,0x8F81,0x4F40,0x8D01,0x4DC0,0x4C80,0x8C41,
0x4400,0x84C1,0x8581,0x4540,0x8701,0x47C0,0x4680,0x8641,
0x8201,0x42C0,0x4380,0x8341,0x4100,0x81C1,0x8081,0x4040 };
short crc8(unsigned short dx,char *p,long n)
{
register unsigned char al;
while (n-- > 0) {
al = (unsigned char)((*p) ^ ((char)(dx & 0xFF)));
dx = (dx>>8) & 0x FF;
dx = dx ^ crctable[al & 0xFF];
p++;
}
return(dx);
}
This function takes as its input an initial CRC value, a pointer to the data to be CRC'd, and the number of
bytes of data. The return value is the new CRC. This function can be used to accumulate a CRC by
running the first set of bytes with an initial value of 0 (or the "starting value" for this type of object), and
subsequent calls with the initial value equal to the last returned CRC.
3 R13-R15 DWG FILE FORMAT ORGANIZATION
R13-R15版本的文件格式
3.1 FILE STRUCTURE 文件结构
notations英[nəʊ'teɪʃnz] 美[noʊ'teɪʃnz]n. 记号,标记法
regarding英[rɪˈɡɑːdɪŋ] 美[rɪˈɡɑːrdɪŋ]prep. 关于;就…而论;至于
arrangement英[əˈreɪndʒmənt] 美[əˈreɪndʒmənt]n. 安排;筹划;布置
The structure of the DWG file format changed between R13 C2 and R13 C3. Notations regarding C3
below indicate the differences.
R13 C2和R13 C3版本的文件格式有变化;C3的不同之处后面有说明;
R13-R15的一般文件布局如下:
The general arrangement of data in an R13/R14/R15 file is as follows:
HEADER头部
FILE HEADER 文件头
DWG HEADER VARIABLES 头部变量
CRC 循环冗余校验
CLASS DEFINITIONS 类定义
TEMPLATE (R13 only, optional) 模版(只有R13有,并且是可选的)
PADDING (R13C3 AND LATER, 200 bytes, minutes the template section above if present)填充位
IMAGE DATA (PRE-R13C3) 图片数据
OBJECT DATA 对象数据
All entities, table entries, dictionary entries, etc. go in this section.所有的实体、表格、字典等;
OBJECT MAP 对象图;
OBJECT FREE SPACE (optional) 对象的自由空间(可选);
TEMPLATE (R14-R15, optional) 模版(可选);
SECOND HEADER 第二个头;
IMAGE DATA (R13C3 AND LATER) 图片数据;
3.2 FILE HEADER 文件头
3.2.1 VERSION ID:版本ID
The first 6 bytes are:
Bytes (ascii encoded) |
Version |
AC1012 |
R13 |
AC1014 |
R14 |
AC1015 |
R2000 |
AC1018 |
R2004 |
AC1021 |
R2007 |
AC1024 |
R2010 |
AC1027 |
R2013 |
AC1032 |
R2018 |
The next 7 starting at offset 0x06 are to be six bytes of 0 (in R14, 5 0’s and the ACADMAINTVER
variable) and a byte of 1. We have occasionally seen other values here but their meaning (and importance)
is unclear.
从第7位开始的6位是0,然后是1个字节的1;有时也会看到其他数据,不过其含义和重要性暂不清楚;
6+6+8=20
3.2.2 IMAGE SEEKER:图片查找器;
At 0x0D is a seeker (4 byte long absolute address) for the beginning sentinel of the image data.
0x0D 是一个图片查找器(4字节的绝对地址),表示图片数据的开始位置;
3.2.3 OBJECT FREE SPACE 对象的自由空间
TODO.
3.2.4 TEMPLATE 模版(可选)
This section is optional, see chapter 22.
3.2.5 DWGCODEPAGE:编码页
Bytes at 0x13 and 0x14 are a raw short indicating the value of the code page for this drawing file.
表示本文件的代码页;
3.2.6 SECTION-LOCATOR RECORDS:节定位记录
At 0x15 is a long that tells how many sets of recno/seeker/length records follow. Each record has the
following format:
0x15 开始的4字节表示记录个数(后面有多少条记录);每个记录的格式如下:
Record number (raw byte) | Seeker (raw long) | Size (raw long)
记录编号(1字节)查找器(4字节)大小(4字节)
The records are as follows:
0 : Header variables (covers beginning and ending sentinels).头部变量
1 : Class section. 类
2 : Object map. 对象图
3 : (C3 and later.) A special table (no sentinels). See unknown section (R13 C3 and
later). The presence of the 4th record (3) indicates that the C3 file format
applies. Just look at the long at 21; if it's 4 or greater, it's the C3-and-later
format.一个特殊的表格;
4 : In R13-R15, points to a location where there may be data stored. Currently we
have seen only the MEASUREMENT variable stored here. See chapter 22. This section
is optional.一个指针,只想数据存储位置;目前我们只看到测量变量存储在这里;这部分是可选的;
Remarks:
We have seen files with up to 6 sets in this section; the meaning of the sixth one
is unknown. The Open Design Toolkit emits files with the first 5 sets only.
这里最多有6套数据,第6套数据含义未知;我们的工具包只使用前5套数据;
RS : CRC for BOF to this point. Use 0 for the initial value, and depending on the
number of sets of section-locators, XOR the result with one of the following:
文件开始的循环冗余校验;用0作为初始值,依赖于有多少套数据,并和下面其中一个进行异或运算;
3 : 0xA598
4 : 0x8101
5 : 0x3CC4
6 : 0x8461
The following 16 byte sentinel appears after the CRC:后面的16字节如下所示:
0x95,0xA0,0x4E,0x28,0x99,0x82,0x1A,0xE5,0x5E,0x41,0xE0,0x5F,0x9D,0x3A,0x4D,0x00
4 R2004 DWG FILE FORMAT ORGANIZATION
4.1 R2004 File Header
Address |
Length |
Description |
0x00 |
6 |
“AC1018” version string 软件版本 |
0x06 |
5 |
5 bytes of 0x00 |
0x0B |
1 |
Maintenance release version 发行版本 |
0x0C |
1 |
Byte 0x00, 0x01, or 0x03 |
0x0D |
4 |
Preview address (long), points to the image page + page header size (0x20). 预览地址,只想图片页和图片头大小; |
0x11 |
1 |
Application version (Acad version that writes the file) 应用程序版本(对文件进行写入的) |
0x12 |
1 |
Application maintenance release version (Acad maintenance version that writes the file) 发行版本(对文件进行写入的) |
0x13 |
2 |
Codepage 代码页 |
0x15 |
3 |
3 0x00 bytes |
0x18 |
4 |
Security flags, default value is 0 (long)安全标签 0x0001 = encrypt data (used for all data sections except AcDb:Preview and AcDb:SummaryInfo) 0x0002 = encrypt properties (used for sections AcDb:Preview and AcDb:SummaryInfo) 0x0010 = sign data 签章数据 0x0020 = add timestamp 时间戳 |
0x1C |
4 |
Unknown long (ODA writes 0) 未知 |
0x20 |
4 |
Summary info Address, points to summary info page + page header size;摘要信息地址,指向摘要信息页; (0x20 |
0x24 |
4 |
VBA Project Address (Optional, write 0 if not present) |
0x28 |
4 |
0x00000080 |
0x2C |
0x54 |
0x00 bytes |
0x80 |
0x6C |
Encrypted Data (see below) 加密数据 |
exclusive英[ɪkˈskluːsɪv] 美[ɪkˈskluːsɪv]adj. 独有的;高档的;排外的;不含…的
The encrypted data at 0x80 can be decrypted by exclusive or’ing the 0x6c bytes of data from the file with
the following magic number sequence:可以使用下面的魔术数字进行解密;
29 23 BE 84 E1 6C D6 AE 52 90 49 F1 F1 BB E9 EB
B3 A6 DB 3C 87 0C 3E 99 24 5E 0D 1C 06 B7 47 DE
B3 12 4D C8 43 BB 8B A6 1F 03 5A 7D 09 38 25 1F
5D D4 CB FC 96 F5 45 3B 13 0D 89 0A 1C DB AE 32
20 9A 50 EE 40 78 36 FD 12 49 32 F6 9E 7D 49 DC
AD 4F 14 F2 44 40 66 D0 6B C4 30 B7
This magic sequence can be generated by the following code, which generates the sequence and stores it
in the data vector:
OdUInt8* p = data.asArrayPtr();
OdUInt32 sz = 0x6c;
int randseed = 1;
while (sz--)
{
randseed *= 0x343fd;
randseed += 0x269ec3;
*p++ = (OdUInt8)(randseed >> 0x10);
}
throughout英[θruːˈaʊt] 美[θruːˈaʊt]prep. 自始至终;遍及adv. 自始至终;遍及
remainder英[rɪˈmeɪndə(r)] 美[rɪˈmeɪndər]n. 剩余物;其他人员;差数;廉价出售的图书
Once decrypted, this sequence of bytes consists of the following data (we will call this data the 2004 File
Header Data throughout the remainder of this document). The file header data is repeated at the end of the
file (this is the second header data).
一旦解密,字节序列将由下面的数据组成(也就是文件头数据,这个数据遍布在文件的其他部分);文件头会在文件尾部再次出现,我们叫他第二文件头;
Address (from start of 0x6c byte sequence) |
Length |
Description |
0x00 |
12 |
“AcFssFcAJMB” file ID string |
0x0C |
4 |
0x00 (long) |
0x10 |
4 |
0x6c (long) |
0x14 |
4 |
0x04 (long) |
0x18 |
4 |
Root tree node gap |
0x1C |
4 |
Lowermost left tree node gap |
0x20 |
4 |
Lowermost right tree node gap |
0x24 |
4 |
Unknown long (ODA writes 1) |
0x28 |
4 |
Last section page Id |
0x2C |
8 |
Last section page end address |
0x34 |
8 |
Second header data address pointing to the repeated header data at the end of the file |
0x3C |
4 |
Gap amount |
0x40 |
4 |
Section page amount |
0x44 |
4 |
0x20 (long) |
0x48 |
4 |
0x80 (long) |
0x4C |
4 |
0x40 (long) |
0x50 |
4 |
Section Page Map Id |
0x54 |
8 |
Section Page Map address (add 0x100 to this value) |
0x5C |
4 |
Section Map Id |
0x60 |
4 |
Section page array size |
0x64 |
4 |
Gap array size |
0x68 |
4 |
CRC32 (long). See paragraph 2.14.2 for the 32-bit CRC calculation, the seed is zero. Note that the CRC calculation is done including the 4 CRC bytes that are initially zero! So the CRC calculation takes into account all of the 0x6c bytes of the data in this table. |
maintenance 英[ˈmeɪntənəns]美[ˈmeɪntənəns]n. 维修; 维护; 保养; 维持; 保持; 抚养费;
The next 0x14 bytes will be copied from the magic number sequence, starting at 0x100 – 0x14. These
0x14 bytes are present in the file header at the beginning of the file, but not at the copy at the end of the
file.后面的20个字节将被拷贝到文件开始文件头,而不会拷贝到文件结尾的文件头;
The remaining data in the file is broken up into sections. There are 2 types of sections, System Sections
and Data Sections. A data section consists of 1 or more section pages, a system section consists of just 1
section page. System sections contain maps to navigate through the data sections and pages. System and
data section pages have different page headers.
剩余的数据将被划分成很多小节;有2种不同的节,系统节和数据节;数据节包括若干页,系统节只有1页;系统节用来导航到所有的数据节和数据页;系统节和数据节的页面有不同的页面标题;
checksum英[ˈtʃeksʌm]校验和
4.2 Section page checksum 节页面的校验和
The following function (pseudocode) is used to calculate system and data page checksums as stored in the
page header (note that system and data page headers are different).
下面的函数用来计算系统页和数据页的校验和,并存储到页面的头部;注意,系统页和数据页的头部是不同的;
OdUInt32 checksum(OdUInt32 seed, OdUInt8* data, OdUInt32 size)
{
OdUInt32 sum1 = seed & 0xffff;
OdUInt32 sum2 = seed >> 0x10;
while (size != 0)
{
OdUInt32 chunkSize = min(0x15b0, size);
size -= chunkSize;
for (int i = 0; i < chunkSize; i++)
{
sum1 += *data++;
sum2 += sum1;
}
sum1 %= 0xFFF1;
sum2 %= 0xFFF1;
}
return (sum2 << 0x10) | (sum1 & 0xffff);
}
4.3 System section page 系统节页面
A System Section page starts with of the following 0x14 bytes of header data:
Address (from start of section) |
Length |
Description |
0x00 |
4 |
Section page type:页面类型 Section page map: 0x41630e3b 页面地图的地址 Section map: 0x4163003b 节地图的地址 |
0x04 |
4 |
Decompressed size of the data that follows 解压缩后的数据大小 |
0x08 |
4 |
Compressed size of the data that follows 压缩后的数据大小 (CompDataSize) |
0x0C |
4 |
Compression type (0x02) 压缩类型 |
0x10 |
4 |
Section page checksum 节页面的校验和 |
Immediately following this data, there will be CompDataSize bytes of compressed data, which is the
actual data for the section. See the Compression section later in this document for details on the
compression algorithm used. After the compressed data there is second header chunk, but fields
decompressed size, compressed size and checksum are set to zero.
压缩数据大小是这个节的真实大小;后面会介绍压缩算法;压缩数据后面是第二标题数据块,但是压缩大小、解压大小、校验和等字段被设置为0;
chunk英[tʃʌŋk] 美[tʃʌŋk]n. 厚块;大量;
The section page checksum is calculated in two stages. First the checksum (using the data page checksum
function) is calculated from the header data, using a seed of 0. The header data’s checksum being 0 at this
stage, but all other fields should be filled. In the second stage the final checksum is calculated from the
compressed data, using the first checksum as the seed.
校验和计算分2步;首先使用校验和函数,对头部数据进行计算,使用种子数据为0;此时校验和的值是0,但是其他字段将被填充数据;第二步,用第一步的校验和作为种子,使用压缩数据进行计算,得到最终的校验和;
Each section page must start on a 0x20 byte boundary of the raw data stream. The empty bytes between
the start of this section and then end of the previous section are filled with as many bytes as needed from
the magic number sequence.
每个节都以0x20 开始,作为数据流的边界;本节开始和上一节结束位置之间的字节,用魔术数字序列进行填充;
System Sections includeSection page map and Section map. These 2 sections serve as a table of contents
for the remaining sections of the file and their pages. Once these 2 sections have been processed, all other
sections in the file can be accessed randomly.
系统节包含页面地图和节地图;这2个节作为后续节和页面的索引表;只有这两个节处理完成后,后续的节才可以访问;
4.4 2004 Section page map
The uncompressed (global) section page map contains the following data:
未压缩的页面地图包含如下数据:
Offset |
Length |
Description |
0x00 |
4 |
Section page number, starts at 1, page numbers are unique per file. 页面编号,从1开始,不能有重复编号 ; |
0x04 |
4 |
Section size 节的大小 |
This repeats, with one number and size for each section page in the file, until the end of the section page
map. Note that this map also contains a reference to the section map, which is a system section. All other
pages are data section pages. The address of each section can be calculated as 0x100 for the first section,
and for each subsequent section the address is the previous section address plus the previous section size.
页面编号和页面编码的数据结构不断重复,直到页面地图结尾的地方;注意,这个地图也包含节地图的引用,也就是系统节的引用;其他页面都是数据页面;以0x100 作为第一个节的地址,后续节的地址只需用该节的地址加上该节的大小即可算出来;
If the section number is negative, this represents a gap in the sections (unused data). For a negative
section number, the following data will be present after the section size:
如果有负数的节编号,表示一个节缺口(无用数据);对于编号是负数的节,其后将会是如下数据:
Offset |
Length |
Description |
0x00 |
4 |
Parent |
0x04 |
4 |
Left |
0x08 |
4 |
Right |
0x0C |
4 |
0x00 |
Taken together, these units of file section information form a vector (1 indexed) of all sections in the file,
and this vector will be referred to as the SectionPageMap throughout the remainder of this document.
taken together英[ˈteɪkən təˈɡeðə] 美[ˈtekən təˈɡɛðɚ]一并考虑
be referred to as被称为;
consecutively英[kən'sekjətɪvlɪ] 美[kən'sekjətɪvlɪ]adv. 连续地
sections英['sekʃənz] 美['sekʃənz]n. 部分( section的名词复数 );节;部件;部门
Section pages are numbered consecutively. The system section pages are the last pages, with a gap of 1
between the page numbers for the data sections and system sections.
页面编号是连续编号的;系统页面是最后一个页面,使用1个间隔,来区分数据节和系统节;
4.5 2004 Data section map
The data section map is a map for locating all data sections (i.e. system sections are not present in this
map).数据节地图用来定位所有数据节,系统节不会出现在这个地图上;
The uncompressed Section Info section contains the following data:
未压缩的节信息包含如下内容:
Offset |
Length |
Description |
0x00 |
4 |
Number of section descriptions (NumDescriptions)编号 |
0x04 |
4 |
0x02 (long) |
0x08 |
4 |
0x00007400 (long) |
0x0C |
4 |
0x00 (long) |
0x10 |
4 |
Unknown (long), ODA writes NumDescriptions here.编号描述 |
Next, the following data is repeated NumDescriptions times:
Offset |
Length |
Description |
0x00 |
8 |
Size of section (OdUInt64)大小 |
0x08 |
4 |
Page count (PageCount). Note that there can be more pages than PageCount, as PageCount is just the number of pages written to file. If a page contains zeroes only, that page is not written to file. These “zero pages” can be detected by checking if the page’s start offset is bigger than it should be based on the sum of previously read pages decompressed size (including zero pages). After reading all pages, if the total decompressed size of the pages is not equal to the section’s size, add more zero pages to the section until this condition is met. 页面数量;表示可能有超出页面数量的页面,因为页面数量只是写入到文件的;如果一个页面只包含0,则这个页面不会写入到文件;如果一个页面的位置比计算得到的位置大,就说明有全0页面;所有页面读完后,如果总大小不等于节大小,那么将添加全0页面,从而保证二者相等; |
0x0C |
4 |
Max Decompressed Size of a section page of this type (normally 0x7400) |
0x10 |
4 |
Unknown (long)未知 |
0x14 |
4 |
Compressed (1 = no, 2 = yes, normally 2)是否压缩 |
0x18 |
4 |
Section Id (starts at 0). The first section (empty section) is numbered 0, consecutive sections are numbered descending from (the number of sections – 1) down to 1. 节的ID,从0开始;第一个节是0号(空节),后面的编号从节的个数-1开始,降序排序,直到减少到1; |
0x1C |
4 |
Encrypted (0 = no, 1 = yes, 2 = unknown) |
0x20 |
64 |
Section Name (string) 节名称 |
Following this, the following (local) section page map data will be present, repeated PageCount times:
Offset |
Length |
Description |
0x00 |
4 |
Page number (index into SectionPageMap), starts at 1 |
0x04 |
4 |
Data size for this page (compressed size). |
0x08 |
8 |
Start offset for this page (OdUInt64). If this start offset is smaller than the sum of the decompressed size of all previous pages, then this page is to be preceded by zero pages until this condition is met. |
Maximum section page size appears to be 0x7400 bytes in the normal case. If a logical section of the file
(the database objects, for example) exceeds this size, then it is broken up into pages of size 0x7400. In
this case, the PageCount value above will contain the number of 0x7400 byte pages, and the data from the
pages can be appended together in order and treated as a single logical section.
Section Types seen so far in 2004 files include (sections are present in the section map in this order):
Section Name |
Description |
Compressed? |
Page size |
-- |
Empty section |
Yes |
0x7400 |
AcDb:Security |
Contains information regarding password and data encryption. This section is optional. |
no |
0x7400 |
AcDb:FileDepList |
Contains file dependencies (e.g. IMAGE files, or fonts used by STYLE). |
no |
0x80 |
AcDb:VBAProject |
Contains VBA Project data for this drawing (optional section) |
no |
Data size + 0x80 + padding size |
AcDb:AppInfo |
Contains information about the application that wrote the .dwg file (encrypted = 2). |
no |
0x80 |
AcDb:Preview |
Bitmap preview for this drawing. |
no |
0x400 |
AcDb:SummaryInfo |
Contains fields like Title, Subject, Author. |
no |
0x100 |
AcDb:RevHistory |
Revision history |
yes |
0x7400 |
AcDb:AcDbObjects |
Database objects |
yes |
0x7400 |
AcDb:ObjFreeSpace |
|
yes |
0x7400 |
AcDb:Template |
Template (Contains the MEASUREMENT system variable only.) |
yes |
0x7400 |
AcDb:Handles |
Handle list with offsets into the AcDb:AcDbObjects section |
yes |
0x7400 |
AcDb:Classes |
Custom classes section |
yes |
0x7400 |
AcDb:AuxHeader |
|
yes |
0x7400 |
AcDb:Header |
Contains drawing header variables |
yes |
0x7400 |
AcDb:Signature |
Not written by ODA |
|
|
The section order in the stream is different than the order in the section map. The order in the stream is as
follows:节的排序
Section: |
节 |
File header |
文件头节 |
Empty section |
空节 |
AcDb:SummaryInfo |
摘要节 |
AcDb:Preview |
预览节 |
AcDb:VBAProject |
VBA节 |
AcDb:AppInfo |
APP信息节 |
AcDb:FileDepList |
? |
AcDb:RevHistory |
修订历史记录 |
AcDb:Security |
安全节 |
AcDb:AcDbObjects |
数据库对象 |
AcDb:ObjFreeSpace |
自由空间 |
AcDb:Template |
模版 |
AcDb:Handles |
句柄 |
AcDb:Classes |
类 |
AcDb:AuxHeader |
辅助标题 |
AcDb:Header |
二头 |
Section map |
节地图 |
Section page map |
页面地图 |
auxiliary英[ɔːɡˈzɪliəri] 美[ɔːɡˈzɪliəri]adj. 辅助的;备用的
免责声明disclaimer
13 Data section AcDb:SummaryInfo Section 摘要节
Section property |
Value |
Name |
AcDb:SummaryInfo 名称 |
Compressed |
1 是否压缩 |
Encrypted |
0 if not encrypted, 1 if encrypted. 是否加密 |
Page size |
0x100 页面大小 |
This section contains summary information about the drawing. Strings are encoded as a 16-bit length,
followed by the character bytes (0-terminated). 这个节包括图纸的摘要信息,字符串编码成2字节,并以0作为结尾;
Type |
Length |
Description |
String |
2 + n |
Title 标题 |
String |
2 + n |
Subject 主题 |
String |
2 + n |
Author 作者 |
String |
2 + n |
Keywords 关键词 |
String |
2 + n |
Comments 评论 |
String |
2 + n |
Last saved by 最后保存 |
String |
2 + n |
Revision number 修订版本 |
String |
2 + n |
Hyperlink base 超链接 |
? |
8 |
Total editing time (ODA writes two zero Int32’s) 总编辑时间 |
Julian date |
8 |
Create date time 创建时间 |
Julian date |
8 |
Modified date time 最后修改时间 |
Int16 |
2 + 2 * (2 +n) |
Property count, followed by PropertyCount key/value string pairs. 属性个数 |
Int32 |
4 |
Unknown (write 0) |
Int32 |
4 |
Unknown (write 0) |
14 Data section AcDb:Preview
14.1PRE-R13C3
Section property |
Value |
Name |
AcDb:Preview 名称 |
Compressed |
1 是否压缩 |
Encrypted |
0 if not encrypted, 1 if encrypted. 是否加密 |
Page size |
If a thumbnail image is present, then header + image data size + sentinels and size info (0x40 bytes) + section alignment padding If no thumbnail image is present, the value is 0x400. 如果有缩略图,页面大小=头部大小+图片大小+大小数据+对齐填充; 如果没有缩略图,则为0x400; |
The BMP (or, sometimes, WMF) image of this file, if any. Only stored here for pre-R13C3 files. Later
files place the data at the end. The format of this data is discussed in the section illustrating where R13C4
and beyond store it.
缩略图可以使bmp或者wmf格式;在pre-R13C3中在这个节存储缩略图;后续的版本中都存储在文件的最后;数据格式将在R13C4及以后版本中讨论,这些版本中存储了这些数据;
illustratingv. 给…加插图( illustrate的现在分词 );说明;表明;(用示例、图画等)说明
15 Data section AcDb:VBAProject Section
The VBA project section is optional.
Section property |
Value |
Name |
AcDb:VBAProject |
Compressed |
1 |
Encrypted |
2 (meaning unknown). |
Page size |
Project data size + 0x80 + section alignment padding |
The contents are currently unknown.The ODA reads and writes the contents of this section as is:
这部分内容暂时未知,ODA按照如下格式进行读写;
Type |
Length |
Description |
byte |
16 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00 |
byte |
n |
The VBA project data |
Int32 |
4 |
0 |
16 Data section AcDb:AppInfo 应用程序信息
Contains information about the application that wrote the .dwg file. This section is optional.
Section property |
Value |
Name |
AcDb:AppInfo |
Compressed |
1 |
Encrypted |
0 |
Page size |
0x80 |
The AppInfo format depends on the application version (Acad version that wrote the file) in the file
header. So a R18 .dwg file might have an R21 AppInfo section.
程序信息取决于应用程序的版本,也就是写该文件的CAD软件;所以R18的DWG文件里面可能会有R21版本的软件信息;
16.1R18
In R18 the app info section consists of the following fields. Strings are encoded as a 16-bit length,
followed by the character bytes (0-terminated).
Type |
Length |
Description |
String |
2 + n |
App info name, ODA writes “AppInfoDataList” |
UInt32 |
4 |
Unknown, ODA writes 2 未知 |
String |
2 + n |
Unknown, ODA writes “4001” 未知 |
String |
2 + n |
App info product XML element, e.g. ODA writes “<ProductInformation name ="Teigha" build_version="0.0" registry_version="3.3" install_id_string="ODA" registry_localeID="1033"/>" 软件信息,XML格式; |
String |
2 + n |
App info version, e.g. ODA writes "2.7.2.0". 软件版本信息,ODA写入的是"2.7.2.0" |
17 Data section AcDb:FileDepList 依赖项列表
Contains file dependencies (e.g. IMAGE files, or fonts used by STYLE).
包含文件的所有依赖项(图片文件、字体文件等);
Section property |
Value |
Name |
AcDb:FileDepList |
Compressed |
1 |
Encrypted |
2 (meaning unknown) |
Page size |
0x80 if number of entries is 0 or 1. If more than 1, then 0x80 x number of entries. |
In R18 the app info section consists of the following fields. Strings are encoded as a 32-bit length,
followed by the character bytes (without trailing 0).
R18版本包含以下字段;字符串是32位的,以0结尾;
Type |
Length |
Description |
Int32 |
4 |
Feature count (ftc) 特征个数 |
String32 |
ftc * (4 + n) |
Feature name list. A feature name is one of the following: 特征名称列表,特征名称是下述名称中的一个; “Acad:XRef” (for block table record)外部参照(用于块表记录) “Acad:Image” (for image definition) 图片(定义图片) “Acad:PlotConfig” (for plotsetting) “Acad:Text” (for text style) |
Int32 |
4 |
File count |
Then follows an array of features (repeated file count times). The feature name + the full filename
constitute the lookup key of a file dependency:
后面是一个特征数据,包括文件名、完整文件名
feature英[ˈfiːtʃə(r)] 美[ˈfiːtʃər]n. 特征;五官;特写;正片,故事片
constitute英[ˈkɒnstɪtjuːt] 美[ˈkɑːnstɪtuːt]v. 组成,构成;被视为;设立
Type |
Length |
Description |
String32 |
4 + n |
Full filename 文件名 |
String32 |
4 + n |
Found path, path at which file was found 文件所在路径 |
String32 |
4 + n |
Fingerprint GUID (applies to xref’s only) 指纹的GUID(仅用于外部参照) |
String32 |
4 + n |
Version GUID (applies to xref’s only) 版本的GUID(仅用于外部参照) |
Int32 |
4 |
Feature index in the feature list above. 上述特征列表的索引 |
Int32 |
4 |
Timestamp (Seconds since 1/1/1980) 时间戳(格林尼治时间) |
Int32 |
4 |
Filesize 文件大小 |
Int16 |
2 |
Affects graphics (1 = true, 0 = false) |
Int32 |
4 |
Reference count 引用的个数 |
18 Data section AcDb:RevHistory 修订历史
Section property |
Value |
Name |
AcDb:RevHistory |
Compressed |
2 |
Encrypted |
0 |
Page size |
0x7400 |
The contents of this section are unknown. In the following paragraphs is described what the ODA writes
in this section.
这节的内容未知;ODA在该节写入下面内容:
18.1R18
Type |
Length |
Description |
UInt32 |
4 |
Unknown (ODA writes 0) |
UInt32 |
4 |
Unknown (ODA writes 0) |
UInt32 |
4 |
Unknown (ODA writes 0) |
More unknown bytes may follow.
19 Data section AcDb:Security 安全节
Section property |
Value |
Name |
AcDb:Security |
Compressed |
1 |
Encrypted |
0 |
Page size |
0x7400 |
This section was introduced in R18. The AcDb:Security section is optional in the file—it is present if the
file was saved with a password.
以R18版本为例介绍该节;安全节是可选的,如果文件设置了密码,就会有安全节;
R18: The section is present in the file if the SecurityType entry at location 0x18 in the file is greater than 0.
如果在0x18位置的SecurityType 值大于0,就说明有安全节;
Strings are prefixed with a 32-bit length (not zero terminated).
这里的字符串指定了一个32位的长度,而不是以0结尾;
Type |
Length |
Description |
Int32 |
4 |
Unknown (ODA writes 0x0c) 未知 |
Int32 |
4 |
Unknown (ODA writes 0x0) 未知 |
Int32 |
4 |
Unknown (ODA writes 0xabcdabcd) 未知 |
UInt32 |
4 |
Cryptographic provider ID 密码提供者ID |
String32 |
4 + n |
Croptographic provider name 密码提供者名称 |
UInt32 |
4 |
Algorithm ID 算法ID |
UInt32 |
4 |
Encryption key length 加密键的长度 |
Int32 |
4 |
Buffer size of following buffer 缓存大小 |
Byte[] |
n |
Encrypted string "SamirBajajSamirB" 加密的字符串 |
cryptographic英['krɪptəʊ'græfɪk] 美[ˌkrɪptə'græfɪk]adj. 关于暗号的,用密码写的
Using the indicated provider and algorithm (and password obtained from the client for this drawing), the
encryption password can be verified by decrypting the Test Encrypted Sequence. If the result is
"SamirBajajSamirB" (0x53, 0x61, 0x6d, 0x69, 0x72, 0x42, 0x61, 0x6a, 0x61, 0x6a, 0x53, 0x61, 0x6d,
0x69, 0x72, 0x42), then the password is correct.
indicated英['ɪndə,keɪtɪd] 美[ 'ɪndə,ketɪd]adj. 表明的;指示的v. 标示( indicate的过去式和过去分词 );指示;象征;
使用明确的提供者和算法(使用绘图人员提供的密码),通过解密测试加密序列,来验证用户的密码是否有效;
如果用提供的密码解密出来的内容恰好是测试序列"SamirBajajSamirB",就说明这个密码是正确的;
The algorithm is RC4 (this is a symmetric encryption algorithm). The algorithm is used in DWG file format version 2004 and 2007.
假面算法用的是RC4(这是一种对称加密算法);在2004和2007版本的DWG文件中使用这种加密算法;
Parameters are:参数如下
- Password (provided by user).密码(用户设置)
- Provider id: e.g. 0x0d. 提供者(设置密码的用户)id;
- Provider name: e.g. "Microsoft Base DSS and Diffie-Hellman Cryptographic Provider".提供者名称;
- Key length: default value is 40. 键长度,默认40;
- Flags: no salt.不使用盐值;
The password bytes (convert unicode password string to bytes, 2 bytes per character) are hashed (using
MD5). A session key is derived from the password hash (using no salt). This session key is then used for
both encryption and decryption.
密码用MD5计算hash值;一个会话密钥从哈希得到;会话密钥同时用于加密和解密;
20 Data section AcDb:AcDbObjects 实体对象
Section property |
Value |
Name |
AcDb:AcDbObjects |
Compressed |
2 |
Encrypted |
0 if not encrypted, 1 if encrypted |
Page size |
0x7400 |
This region holds the actual objects in the drawing. These can be entities, table entries, dictionary entries,
and objects. This second use of objects is somewhat confusing; all items stored in the file are “objects”,
but only some of them are object objects. Others are entities, table entries, etc. The objects in this section
can appear in any order.
该节保存绘图中实际使用的对象;这些对象可能是实体、表格、字典、对象;对象的第二种使用方法有些难以理解;所有的元素在文件中都保存为对象,但是只有其中一部分是物体对象;其他的是实体、表格等;这些对象的顺序并不固定;
confusing英[kənˈfjuːzɪŋ] 美[kənˈfjuːzɪŋ]adj. 难以理解的
Not all objects present in the file are actually used. All used objects can eventually be traced back to
handle references in the Header section. So the proper way to read a file is to start reading the header and
then tracing all references from there until all references have been followed. Very occasionally a file
contains e.g. two APPID objects with the same name, of which one is used, and the other is not. Reading
both would be incorrect due to a name clash. To complicate matters more, files also exist with table
records with duplicate names. This is incorrect, and the software should rename the record to be unique
upon reading.
文件中的所有对象不一定都会使用;那些被使用的对象可以再文件头中找到相应的句柄引用;所以要读取一个DWG文件,应该首先从头部找到所有引用,然后根据引用指向的 地址找出对象;很偶然的情况下,一个文件中会出现两个同名的APPID对象,这两个对象中有一个被使用了,而另一个没有被使用;如果同时读取两个同名对象,会造成名称冲突,从而导致错误;这是不正确的,并且软件应当把重名的对象改成唯一名称;
For R18 and later the section data (right after the page header) starts with a RL value of 0x0dca (meaning
unknown).
对于R18版本或者更高,本节的数据从0x0dca 开始;
20.1Common non-entity object format 非实体对象的格式
Objects (non-entities) have the following general format:非实体对象的格式如下所示
assign英[əˈsaɪn] 美[əˈsaɪn]v. 指派(任务);给予
unsigned英['ʌn'saɪnd] 美[ʌn'saɪnd]adj. 无符号的,无正负之分的
Version |
Field type |
DXF group |
Description |
MS |
Size in bytes of object, not including the CRC 对象的大小,不包括循环冗余校验部分; |
|
|
R2010+ |
|
|
|
MC |
Size in bits of the handle stream (unsigned, 0x40 is not interpreted assign). This includes the padding bits at the end of the handle stream (the padding bits make sure the object stream ends on a byte boundary). 句柄流的大小(以位为单位),是无符号数,0x40 没有分配;
|
|
|
Commmon |
|
|
|
OT |
Object type 对象的类型 |
|
|
R2000-R2007 |
|
|
|
RL |
Size of object data in bits (number of bits before the handles), or the “endbit” of the pre-handles section.对象大小,以位为单位(在句柄之前的位的个数),或者是在句柄之前的结束位; |
|
|
Common: |
|
|
|
|
H |
5 |
Object’s handle |
|
BS |
|
Size of extended object data, if any |
|
X |
|
Extended object data, if any. See EED section, chapter 28. |
20.2 Common entity format 常用实体格式
Drawing entities, which are of course objects, have the same format as objects, with some additional
standard items:
绘图实体,属于进程对象,都有相同的格式,还拥有一些标准元素:
MS : Size of object, not including the CRC 对象大小,不含CRC
R2010+:
MC : Size in bits of the handle stream (unsigned, 0x40 is not interpreted as sign).句柄流大小
Commmon:
OT : Object type 对象类型
R2000+ Only:
RL : Size of object data in bits 对象数据大小
Common:
H : Object’s handle 对象句柄
BS : Size of extended object data, if any 扩展数据大小,如有
X : Extended object data, if any 扩展数据,如有
B : Flag indicating presence of graphic image. 是否有图片
if (graphicimageflag is 1) { 如果有图片
R13-R007:
RL: Size of graphic image in bytes 图片大小
R2010+:
BLL: Size of graphic image in bytes图片大小
Common:
X: The graphic image 图片
}
R13-R14 Only:
RL : Size of object data in bits 对象大小
6B : Flags 标志
6B : Common parameters 公共参数
R2000+ Only:
B : 0 if the previous and next linkers are present; 1 if they are BOTH defaults (1
back and 1 forward). 0表示有链接,1表示默认值;
ENC : Entity color 颜色
BD : Linetype Scale 线型
BB : Line type flags 线型标志
00 – BYLAYER linetype 线型(按图层)
01 – BYBLOCK linetype 线型(按块)
10 – CONTINUOUS linetype 线型(连续线)
11 – Indicates that a linetype handle will be stored in the handles section of the
entity. 线型句柄
BB : Plotstyle flags: 打印样式标志
00 – BYLAYER plotstyle 打印样式(按图层)
01 – BYBLOCK plotstyle 打印样式(按块)
10 – CONTINUOUS plotstyle 打印样式(连续线)
11 – Indicates that a plotstyle handle will be stored in the handles section of
the entity. 打印样式句柄
R2007+:
BB : Material flags: 材质标志
00 – BYLAYER material 材质(按图层)
01 – BYBLOCK material 材质(按块)
10 – global material? 全局材质
11 – Indicates that a material handle will be stored in the handles section of the
entity. 材质句柄
RC : Shadow flags 阴影标志
R2010+:
B : Has full visual style 完全样式
B : Has face visual style 面样式
B : Has edge visual style 边样式
Common:
BS : Invisible flag (bit 0: 0 = visible, 1 = invisible) 是否可见
R2000+:
RC : Entity lineweight flag 线宽标志
Common:
X : Object data (varies by type of object) 对象数据(不同对象的数据有所不同)
X : Handles associated with this object 该对象的句柄
B* : Padding bits are added until the next byte boundary is reached. 填充到下一个字节边界
RS : CRC 校验
varies英['veərɪz] 美['veərɪz]v. 变化( vary的第三人称单数 );[生物学]变异;相应变化;呈现不同
The R13-R14 FLAGS area (6 bits) indicates which handle references are present in the HANDLE REFS
area. They are as follows: R13-R14版本中的标志,表示句柄引用,如下所示:
FEDCBA
FE : Entity mode (entmode). Generally, this indicates whether or not the owner
relative handle reference is present. The values go as follows:
实体模式,表示是否有主人的引用;这个值如下:
00 : The owner relative handle reference is present.00表示有主人句柄;
Applies to the following:适用于以下情形
VERTEX, ATTRIB, and SEQEND.顶点、特性、序列结尾;
BLOCK, ENDBLK, and the defining entities in all
block defs except *MODEL_SPACE and *PAPER_SPACE.
块、结束块和块中定义的所有实体,模型空间和图纸空间除外;
01 : PSPACE entity without a owner relative handle ref.01表示没有主人的句柄(图纸空间);
10 : MSPACE entity without a owner relative handle ref.10表示没有主人句柄(模型空间);
11 : Not used.未使用;
DC : This is the number of reactors attached to an entity as a bitshort. This feature
may have been dormant in R13, but it appears in R14, and in files saved as R13 by
R14.
reactors英[r'ɪæktəz] 美[r'ɪæktəz]n. 起反应的人( reactor的名词复数 );反应装置;原子炉;核反应堆
dormant英[ˈdɔːmənt] 美[ˈdɔːrmənt]adj. 休眠的;蛰伏的;暂停活动的
实体上附属的反应器的个数,用2字节表示;R13中,这个属性可能无法使用,但是在R14版本中可用,用R14保存成R13的文件中也可用;
B : 0 if a linetype reference is present; 1 if it's not (the default being BYLAYER --
even though there IS a BYLAYER linetype entity and it has a handle).
表示有没有线型的引用,0表示有1没有;默认的线型是按图层
A : 0 if the previous and next linkers are present; 1 if they are BOTH defaults (1
back and 1 forward). 0表示有链接,1表示默认值;
The COMMON PARAMETERS (6 bits):
CCSSII
CC : Color bitshort
SS : Linetype scale bitdouble
II : "Invisible" flag bitshort (bit 0: 0 = visible, 1 = invisible).
The ENTITY-SPECIFIC PARAMETERS area is coded with bitcodes. Each entity has its own parameter
prescription. Some parameters ALWAYS appear in raw form -- even if bitcode abbreviations could be
used (the 10 and 11 points in TEXT, for example). Generally the raw form is used in conditions wherein
it cannot reasonably be assumed that the likely value for the particular parameter is one of the
compressible values.
prescription英[prɪˈskrɪpʃn] 美[prɪˈskrɪpʃn]n. [医]药方,处方;处方药;训令,指示;法规
实体说明参数部分使用位编码;每个实体都有各自的参数;有些参数始终都会出现,即使使用了缩写;
原始数据用于可压缩的值;
One method for loading these objects is to follow the object map. Doing so will cause each object to be
loaded once and only once. Alternatively one can try to scan the objects as they are found, and replace
objects with duplicated object handles with the ones found later in the file. The Teigha Classic for .dwg
files Toolkit uses a hybrid approach, loading the control objects first, then the objects they contain.
获取对象的方式是使用对象地图;用这种方法会将对象加载一次,且只有一次;另外也可以扫描文件来获取对象,或者用一个复制的句柄来代替该对象;Teigha使用混合方式来获取对象,首先加载控制对象,然后加载其中(控制对象)包含的对象;
20.3 Object types 对象类型
Some object types have fixed values, others have values which vary with the drawing. Here are the fixed
values:有些对象有固定的值,有些对象有变化的值;下面是一些固定的值:
UNUSED 0 未使用 RAY 0x28 射线
TEXT 1 文本 XLINE 0x29
ATTRIB 2 特性 DICTIONARY 0x2A
ATTDEF 3 OLEFRAME 0x2B
BLOCK 4 块 MTEXT 0x2C 多行文本
ENDBLK 5 结束块 LEADER 0x2D
SEQEND 6 TOLERANCE 0x2E
INSERT 7 MLINE 0x2F 多线
MINSERT 8 BLOCK CONTROL OBJ 0x30
9 BLOCK 块 HEADER 0x31 头部
VERTEX (2D) 0x0A 顶点 LAYER CONTROL OBJ 0x32 图层
VERTEX (3D) 0x0B 顶点 LAYER 0x33 图层
VERTEX (MESH) 0x0C 网格顶点 STYLE CONTROL OBJ 0x34
VERTEX (PFACE) 0x0D 面顶点 STYLE 0x35
VERTEX (PFACE FACE) 0x0E 0x36
POLYLINE (2D) 0x0F 0x37 多段线
POLYLINE (3D) 0x10 多段线 LTYPE CONTROL OBJ 0x38
ARC 0x11 圆弧 LTYPE 0x39 线型
CIRCLE 0x12 0x3A
LINE 0x13 0x3B
DIMENSION (ORDINATE) 注释 0x14 VIEW CONTROL OBJ 0x3C 视图
DIMENSION (LINEAR) 0x15 VIEW 0x3D
DIMENSION (ALIGNED) 0x16 UCS CONTROL OBJ 0x3E
DIMENSION (ANG 3-Pt) 0x17 UCS 0x3F 坐标
DIMENSION (ANG 2-Ln) 0x18 VPORT CONTROL OBJ 0x40
DIMENSION (RADIUS) 0x19 VPORT 0x41
DIMENSION (DIAMETER) 0x1A APPID CONTROL OBJ 0x42
POINT 0x1B APPID 0x43 点
3DFACE 0x1C DIMSTYLE CONTROL OBJ 0x44
POLYLINE (PFACE) 多段线 0x1D DIMSTYLE 0x45 标注样式
POLYLINE (MESH) 0x1E VP ENT HDR CTRL OBJ 0x46
SOLID 0x1F 实线 VP ENT HDR 0x47
TRACE 0x20 GROUP 0x48 组
SHAPE 0x21 MLINESTYLE 0x49
VIEWPORT 0x22 视口 OLE2FRAME 0x4A
ELLIPSE 0x23 (DUMMY) 0x4B
SPLINE 0x24 LONG_TRANSACTION 0x4C
REGION 0x25 区域 LWPOLYLINE 0x4D
3DSOLID 0x26 三维实体 HATCH 0x4E
BODY 0x27 XRECORD 0x4F
ACDBPLACEHOLDER 0x50
VBA_PROJECT 0x51
LAYOUT 0x52 布局
ACAD_PROXY_ENTITY 0x1f2 代理实体
ACAD_PROXY_OBJECT 0x1f3 代理对象
There are a number of objects with non-fixed values. These are: 非定值对象:
ACAD_TABLE 表格
CELLSTYLEMAP 单元格样式
DBCOLOR 颜色
DICTIONARYVAR
DICTIONARYWDFLT 字典
FIELD 字段
GROUP 组
HATCH 填充
IDBUFFER 缓存
IMAGE 图像
IMAGEDEF 图像定义
IMAGEDEFREACTOR
LAYER_INDEX 图层索引
LAYOUT 布局
LWPLINE
MATERIAL 材质
MLEADER 引线
MLEADERSTYLE 引线样式
OLE2FRAME
PLACEHOLDER 占位符
PLOTSETTINGS 打印设置
RASTERVARIABLES
SCALE 缩放
SORTENTSTABLE 排序表格
SPATIAL_FILTER 空间过滤器
SPATIAL_INDEX 空间索引
TABLEGEOMETRY 表格几何体
TABLESTYLES 表格样式
VBA_PROJECT
VISUALSTYLE 视觉样式
WIPEOUTVARIABLE
XRECORD
For objects with non-fixed values, taking the object type minus 500 gives an index into the class list,
which then determines the type of object. For instance, an object type of 501 means that this object is of
the class which is second in the class list; the classdxfname field determines the type of the object.
See the sections on EED a description of that areas.
对于非定值对象,可以用对象类型减去500获得类列表的索引,然后就能获取对象的类型了;
例如,一个对象的类型是501,那么类型索引就是501-500=1,也就是类型列表中的第二个成员(0开始);
20.4 OBJECT PRESCRIPTIONS 对象处方?
prescriptions英[prɪsk'rɪpʃnz] 美[prɪsk'rɪpʃnz]n. 规定;处方;开处方;计划
prescription英[prɪˈskrɪpʃn]美[prɪˈskrɪpʃn]n. (条例、指示、命令、法令等)规定 ; 处方
prescript 规定,规定 规定; 处方;
The object prescriptions are given in the following form:对象处方格式如下
ITEM TYPE-CODE DXF-CODE DESCRIPTION 元素 类型编码 图形交换码 处方
See the top of this document for the key to the data types used here.
20.4.1 Common Entity Data 常用实体数据
The following data appears at the beginning of each entity in the file, and will be referred to as Common
Entity Data in the subsequent entity descriptions.
下面的数据在每个实体的开头部分,被称为实体数据,这些数据在后续的实体描述信息中;
Length MS --- Entity length (not counting itself or CRC).实体长度(不含自身长度和CRC)
Type BS 0 1 (internal DWG type code).
R2000+ Only:
Obj size RL size of object in bits, not including end handles
Common:
Handle H 5 code 0, length followed by the handle bytes.
EED size BS size of extended entity data, if any
EED X -3 See EED section.
Graphic present Flag B 1 if a graphic is present
Graphics X if graphicpresentflag is 1, the graphic goes here.
See the section on Proxy Entity Graphics for the
format of this section.
R13-R14 Only:
Obj size RL size of object in bits, not including end handles
Common:
Entmode BB entity mode
Numreactors BL number of persistent reactors attached to this
object
R2004+:
XDic Missing Flag B If 1, no XDictionary handle is stored for this
object, otherwise XDictionary handle is stored as in
R2000 and earlier.
R2013+:
Has DS binary data B If 1 then this object has associated binary data
stored in the data store. See for more details
chapter 24.
R13-R14 Only:
Isbylayerlt B 1 if bylayer linetype, else 0
Common:
Nolinks B 1 if major links are assumed +1, -1, else 0
For R2004+ this always has value 1
(links are not used)
Color CMC(B) 62
Ltype scale BD 48
R2000+:
Ltype flags BB 00 = bylayer, 01 = byblock, 10 = continous, 11 =
linetype handle present at end of object
Plotstyle flags BB 00 = bylayer, 01 = byblock, 11 = plotstyle handle
present at end of object
R2007+:
Material flags BB 00 = bylayer, 01 = byblock, 11 = material handle
present at end of object
Shadow flags RC
Common:
Invisibility BS 60
R2000+:
Lineweight RC 370
20.4.2 Common Entity Handle Data 常用实体句柄
be referred to as被称为…
subsequent英[ˈsʌbsɪkwənt] 美[ˈsʌbsɪkwənt]adj. 后来的;随后的;作为结果而发生的;附随的
The following data appears in the handles section of each entity, and will be referred to as Common
Entity Handle Data in the subsequent entity descriptions.
下面的数据出现在每个实体的句柄部分,被称为后面的实体描述信息的实体句柄数据;
Handle refs
[Owner ref handle (soft pointer)]
[Reactors (soft pointer)]
xdicobjhandle (hard owner)
R13-R14 Only:
8 LAYER (hard pointer)
6 [LTYPE (hard pointer)] (present if Isbylayerlt is 0)
R13-R2000 Only:
previous/next handles present if Nolinks is 0
[PREVIOUS ENTITY (relative soft pointer)]
[NEXT ENTITY (relative soft pointer)]
R2004+:
[Color book color handle (hard pointer)]
R2000+ Only:
8 LAYER (hard pointer)
6 [LTYPE (hard pointer)] present if linetype flags were 11
R2007+:
MATERIAL present if material flags were 11
R2000+:
PLOTSTYLE (hard pointer) present if plotstyle flags
were 11
R2010+:
If has full visual style, the full visual style handle (hard pointer).
If has face visual style, the face visual style handle (hard pointer).
If has edge visual style, the full visual style handle (hard pointer).
20.4.3 TEXT (1) 文本数据
elevation 高程 英[ˌelɪˈveɪʃn]美[ˌelɪˈveɪʃn]n. 高程; 提升; 提拔;(某地方的)高度; (尤指)海拔; 高地; 高处;
oblique英[əˈbli:k] 美[oˈblik, əˈblik]adj. 斜,倾斜的;
Common Entity Data
R13-14 Only:
Elevation BD --- 高程、高度
Insertion pt 2RD 10 插入点坐标
Alignment pt 2RD 11 对齐点坐标
Extrusion 3BD 210 挤出坐标
Thickness BD 39 厚度
Oblique ang BD 51 斜体字、倾斜角度
Rotation ang BD 50 旋转角度
Height BD 40 高度
Width factor BD 41 宽度系数
Text value TV 1 文本内容
Generation BS 71
Horiz align. BS 72 水平对齐
Vert align. BS 73 垂直对齐
R2000+ Only:
DataFlags RC Used to determine presence of subsquent data 标志位,决定了是否有后续的数据
Elevation RD --- present if !(DataFlags & 0x01) 高程、高度
Insertion pt 2RD 10 插入点位置
Alignment pt 2DD 11 present if !(DataFlags & 0x02), use 10 & 20 values 对齐点位置
for 2 default values.
Extrusion BE 210
Thickness BT 39
Oblique ang RD 51 present if !(DataFlags & 0x04)
Rotation ang RD 50 present if !(DataFlags & 0x08)
Height RD 40
Width factor RD 41 present if !(DataFlags & 0x10)
Text value TV 1
Generation BS 71 present if !(DataFlags & 0x20)
Horiz align. BS 72 present if !(DataFlags & 0x40)
Vert align. BS 73 present if !(DataFlags & 0x80)
Common:
Common Entity Handle Data 实体句柄
H 7 STYLE (hard pointer)
CRC X ---
20.4.5 ATTDEF (3) 属性
Common ATTRIB Entity Data 属性实体数据
R2010+:
Version RC ? 版本
Common:
Prompt TV 3
CRC X ---
20.4.6 BLOCK (4) 块
Common Entity Data 实体数据
Block name TV 2 块名
Common Entity Handle Data 实体句柄
CRC X --- 校验数据
20.4.7 ENDBLK (5) 结束块
Common Entity Data 实体数据
Common Entity Handle Data 实体句柄
CRC X --- 校验数据
20.4.18 ARC (17) 圆弧
Common Entity Data
Center 3BD 10 圆心
Radius BD 40 半径
Thickness BT 39 宽度
Extrusion BE 210 挤出
Start angle BD 50 开始角度
End angle BD 51 结束角度
Common Entity Handle Data 句柄
CRC X --- 校验
20.4.19 ARC_DIMENSION 圆弧的标注
Class properties:类属性
maintenance 英[ˈmeɪntənəns]美[ˈmeɪntənəns]n. 维修; 维护; 保养;
App name |
ObjectDBX Classes 名称 |
Class number |
Dynamic (>= 500) 类编号 |
DWG version |
R18 DWG版本呢 |
Maintenance version |
0 维护版本 |
Class proxy flags |
0x401 |
C++ class name |
AcDbArcDimension C++类名 |
DXF name |
ARC_DIMENSION DXF名称 |
The arc length dimension was introduced in AutoCAD 2004. The DXF format is slightly different from
the other dimension entities. The entity type in DXF is ARC_DIMENSION, rather than DIMENSION.
Common Entity Data
Common Dimension Data Common: Dim line arc point |
See paragraph 20.4.22. |
3BD |
10 |
Extension line 1 point 3BD 13 延伸线的点
Extension line 2 point 3BD 14 延伸线的点
Arc center 3BD 15 圆心
Is partial? B 70
Start angle (radians) BD 40 起始角度
End angle (radians) BD 41 结束角度
Has leader? B 71 是否有引线
Leader point 1 3BD 16 引线的点
Leader point 2 3BD 17 引线的点
Common Entity Handle Data 句柄
H 3 DIMSTYLE (hard pointer) 标注类型
H 2 anonymous BLOCK (hard pointer) 匿名块
CRC X --- 校验
20.4.20 CIRCLE (18) 圆
Common Entity Data
Center 3BD 10
Radius BD 40
Thickness BT 39
Extrusion BE 210
Common Entity Handle Data
CRC X ---
20.4.20.1 R14 Example:
OBJECT: circle (12H), len 2BH (43), handle: 92
20.4.21 LINE (19) 直线
Common Entity Data
R13-R14 Only:
Start pt 3BD 10 起始点
End pt 3BD 11 结束点
R2000+:
Z’s are zero bit B
Start Point x RD 10 起始点x
End Point x DD 11 Use 10 value for default 结束点x
Start Point y RD 20 起始点y
End Point y DD 21 Use 20 value for default 结束点y
Start Point z RD 30 Present only if “Z’s are zero bit” is 0 起始点z
End Point z DD 31 Present only if “Z’s are zero bit” is 0, use 30 结束点z
value for default.
Common:
Thickness BT 39 宽度(线宽)
Extrusion BE 210 挤出
Common Entity Handle Data 句柄
CRC X --- 校验
20.4.33 POLYLINE (PFACE) (29) 多段线
Common Entity Data
Numverts BS 71 Number of vertices in the mesh.顶点个数
Numfaces BS 72 Number of faces 面个数
R2004+:
Owned Object Count BL Number of objects owned by this object.
Common:
Common Entity Handle Data 句柄
R13-R2000:
H first VERTEX (soft pointer) 起始顶点
H last VERTEX (soft pointer) 结束顶点
R2004+:
H [VERTEX (soft pointer)] Repeats “Owned Object Count” times.
Common:
H SEQEND (hard owner)
CRC X --- 校验
20.4.39 ELLIPSE (35) 椭圆
Note that the 10 pt and the 11 vector are WCS -- even though an ellipse is planar and has an extrusion
vector (210-group).
Common Entity Data
Center 3BD 10 (WCS)
SM axis vec 3BD 11 Semi-major axis vector (WCS)
Extrusion 3BD 210
Axis ratio BD 40 Minor/major axis ratio
Beg angle BD 41 Starting angle (eccentric anomaly, radians)
End angle BD 42 Ending angle (eccentric anomaly, radians)
Common Entity Handle Data
CRC X ---
20.4.42 RAY (40) 射线
Common Entity Data
Point 3BD 10 点
Vector 3BD 11 向量
Common Entity Handle Data
CRC X ---
20.4.44 DICTIONARY (42) 字典
Basically a list of pairs of string/objhandle that constitute the dictionary entries.
字符串和对象句柄组成一对,很多个这样的对组成一个列表,他们组成了字典的入口;
Length MS --- Entity length (not counting itself or CRC).
Type S 0 42 (internal DWG type code).
R2000+:
Obj size RL size of object in bits, not including end handles 对象大小
Common:
Handle H 5 Length (char) followed by the handle bytes.对象句柄
EED X -3 See EED section.
R13-R14 Only:
Obj size RL size of object in bits, not including end handles 对象大小
Common:
Numreactors S number of reactors in this object 反应堆的个数
R2004+:
otherwise英[ˈʌðəwaɪz] 美[ˈʌðərwaɪz]adv. 否则;除此以外;与之不同地;以其他方式
XDic Missing Flag B If 1, no XDictionary handle is stored for this
object, otherwise XDictionary handle is stored as in
R2000 and earlier.
Common:
Numitems L number of dictonary items 字典中元素个数
R14 Only:
Unknown R14 RC Unknown R14 byte, has always been 0 未知字节,始终是0
R2000+:
Cloning flag BS 281
Hard Owner flag RC 280
Common:
Text TV string name of dictionary entry, numitems entries
Handle refs H parenthandle (soft relative pointer) 父亲的句柄
[Reactors (soft pointer)]
xdicobjhandle (hard owner)
20.4.46 MTEXT (44) 多行文本
Common Entity (Handle) Data
Insertion pt3 BD 10 First picked point. (Location relative to text 插入点坐标
depends on attachment point (71).)
Extrusion 3BD 210 Undocumented; appears in DXF and entget, but ACAD
doesn't even bother to adjust it to unit length.
X-axis dir 3BD 11 Apparently the text x-axis vector. (Why not just a
rotation?) ACAD maintains it as a unit vector. x轴方向,单位向量
Common:
Rect width BD 41 Reference rectangle width (width picked by the user).矩形框宽度
R2007+:
Rect height BD 46 Reference rectangle height. 矩形框高度
Common:
Text height BD 40 Undocumented 文本高度
Attachment BS 71 Similar to justification; see DXF doc
Drawing dir BS 72 Left to right, etc.; see DXF doc 绘制方向
Extents ht BD --- Undocumented and not present in DXF or entget 扩展高度
Extents wid BD --- Undocumented and not present in DXF or entget 扩展宽度
Text TV 1 All text in one long string (without '\n's
3 for line wrapping). ACAD seems to add braces ({ })
and backslash-P's to indicate paragraphs based on
the "\r\n"'s found in the imported file. But, all
the text is in this one long string -- not broken
into 1- and 3-groups as in DXF and entget.
ACAD's entget breaks this string into 250-char
pieces (not 255 as doc'd) – even if it's mid-word.
The 1-group always gets the tag end; therefore, the
3's are always 250 chars long.
H 7 STYLE (hard pointer)
R2000+:
Linespacing Style BS 73
Linespacing Factor BD 44
Unknown bit B
R2004+:
Background flags |
BL |
90 |
0 = no background, 1 = background fill, 2 = background fill with drawing fill color, 0x10 = text |
frame (R2018+)
IF background flags has bit 0x01 set, or in case of R2018 bit 0x10:
Background scale factor
BL 45 default = 1.5
Background color CMC 63
Background transparency
BL 441
END IF background flags 0x01/0x10
R2018+
Is NOT annotative B
IF MTEXT is not annotative
Version BS Default 0
Default flag B Default true
BEGIN REDUNDANT FIELDS (see above for descriptions)
Registered application H Hard pointer
Attachment point BL
X-axis dir 3BD 10
Insertion point 3BD 11
Rect width BD 40
Rect height BD 41
Extents width BD 42
Extents height BD 43
END REDUNDANT FIELDS
Column type BS 71 0 = No columns, 1 = static columns, 2 = dynamic
columns
IF Has Columns data (column type is not 0)
Column height count BL 72
Columnn width BD 44
Gutter BD 45
Auto height? B 73
Flow reversed? B 74
IF not auto height and column type is dynamic columns
REPEAT Column heights
Column height BD 46
END REPEAT
END IF (has column heights)
END IF (has columns data)
END IF (not annotative)
Common:
CRC X ---
UCS用户坐标系(User Coordinate System);
20.4.96 TABLE (varies) 表格
The TABLE entity (entity type ACAD_TABLE) was introduced in AutoCAD 2005 (a sub
release of R18), and a large number of changes were introduced in AutoCAD 2008 (a sub release of
R21). The table entity inherits from the INSERT entity. The geometric results, consisting of table borders,
texts and such are created in an anonymous block, similarly to the mechanism in the DIMENSION entity.
The anonymous block name prefix is “*T”. For the AutoCAD 2008 changes see paragraph 20.4.96.2.
TODO: document roundtrip data with connections to AcDbTableContent and
AcDbTableGeometry.
在CAD2005版(R18)开始引入表格,相比于2008有很大变化;表格继承自插入实体;包括表格边框、文本、匿名块,类似于标注;匿名刈名称以T为前缀;
20.4.96.1 Until R21
This paragraph describes the table DWG format until R21. In R24 the format was changed to make use of
table content to contain all data (AcDbTableContent).
21 Data section AcDb:ObjFreeSpace自由空间
The meaning of this section is not completely known. The ODA knows how to write a valid section, but
the meaning is not known of every field.
这个节的含义并不完全清楚;但是ODA直到如何写一个有效的节,只是字段的含义不清楚而已;
22 Data section: AcDb:Template 模板
mandatory英[ˈmændətəri] 美[ˈmændətɔːri]adj. 强制的;命令的;受委托的
This section is optional in releases 13-15. The section is mandatory in the releases 18 and newer. The
template section only contains the MEASUREMENT system variable.
R13-15版本中,这个节是可选的;在R18或者更新的版本中,这个节是必须的;模板节仅仅包含测量相关的系统变量;
Type |
Length |
Description |
Int16 |
2 |
Template description string length in bytes (the ODA always writes 0 here).描述字符串的长度,以字节为单位,ODA一般写0; |
byte[] |
n |
Encoded string bytes of the template description (use the drawing’s codepage to encode the bytes).描述字符串的编码; |
UInt16 |
2 |
MEASUREMENT system variable (0 = English, 1 = Metric). 测量单位:0表示英制单位、1表示米制单位; |
23 Data section AcDb:Handles (OBJECT MAP) 对象地图
23.1R13-15
The Object Map is a table which gives the location of each object in the file This table is broken into
sections. It is basically a list of handle/file loc pairs, and goes (something like) this:
对象地图是一个表格,其中列出了每个对象在文件中的位置;这个表格被拆分成多个部分;基本上是句柄/文件位置键值对,如下所示:
Set the "last handle" to all 0 and the "last loc" to 0L;
Repeat until section size==2 (the last empty (except the CRC) section):
Short: size of this section. Note this is in BIGENDIAN order (MSB
first)
Repeat until out of data for this section:
offset of this handle from last handle as modular char.句柄偏移量
offset of location in file from last loc as modular char. (note
that location offsets can be negative, if the terminating byte
has the 4 bit set).文件中的位置偏移量
End repeat.
CRC (most significant byte followed by least significant byte)
End of section
End top repeat
Note that each section is cut off at a maximum length of 2032.
24 Section AcDb:AcDsPrototype_1b (DataStorage)
数据存储
At this moment (December 2012), this sections contains information about Acis data (regions, solids).
The data is stored in a byte stream, not a bit stream like e.g. the objects section.
The data store contains several data segments, and index segments that contain lookup information for
finding the data segments and objects within these data segments. The file header contains the stream
position of the segment index file segment and the segment indexes for the schema index/data
index/search file segments. The segment index file segment is a lookup table for finding the stream
position of a file segment by its segment index.
In paragraph 24.3 the default contents of this section is shown when empty.
25 UNKNOWN SECTION 未知节
This section is largely unknown. The total size of this section is 53. We simply patch in "known to be
valid" data. We first write a 0L, then the number of entries in the objmap +3, as a long. Then 45 bytes of
"known to be valid data". Then we poke in the start address for objects at offset 16.
26 SECOND FILE HEADER (R13-R15)
27 Data section: AcDb:AuxHeader (Auxiliary file
header)辅助节
The auxiliary file header contains mostly redundant information and was introduced in R15.
28 Extended Entity Data 扩展实体数据
(Extended Object Data)
EED directly follows the entity handle.
Each application's data is structured as follows:
|Length|Application handle|Data items|
Length is a bitshort indicating the length of the data for an app, not including itself, the bit-pair, or the app
table handle. The above format repeats until a length of zero is found.
The application handle is a standard table handle reference: 0101|4-bit length|handle bytes|
Each data item has a 1-byte code (DXF group code minus 1000) followed by the value. It looks like
there's no bit-pair coding within the data; that would throw off the length value (it would need to count
bits, too). The form of the value is listed below for each type:
29 PROXY ENTITY GRAPHICS 代理图形
Proxy entities (zombies prior to R14) can have associated graphics data. The presence or absence of this
data is indicated by the single bit which we call the “graphic present flag”, which mostly occurs on entitytype proxies, and very few other entities. Entity type proxies are proxies where the related class’s
itemclassid field is equal to 0x1F2.
代理实体可以拥有相关的图形数据;有一个标志位来表示是否有该部分数据,他通常出现在实体类型代理中,而很少出现在实体中;只有itemclassid 字段的值是0x1F2才能代理;
If that bit is 1, then following it, and preceding the RL which indicates the number of bits in the object, is
an RL which indicates the number of bytes of proxy entity graphic data to follow.
Graphics data is padded to 4 byte boundaries! So, for instance, strings which are too short are padded out
to the next 4 byte boundary. Similarly for lists of shorts.
In addition to the data definitions from chapter 2 there are a few additional data types:
PS : Padded string. This is a string, terminated with a zero byte. The file’s text encoding (code page)
is used to encode/decode the bytes into a string.
PUS : Padded Unicode string. The bytes are encoded using Unicode encoding. The bytes consist of
byte pairs and the string is terminated by 2 zero bytes.
We use the following defines to discriminate sub-item presence:
#define adHasPrimTraits(a) (a & 0xFFFFL)
#define adPrimsHaveColors(a) (a & 0x0001L)
#define adPrimsHaveLayers(a) (a & 0x0002L)
#define adPrimsHaveLinetypes(a) (a & 0x0004L)
#define adPrimsHaveMarkers(a) (a & 0x0020L)
#define adPrimsHaveVisibilities(a) (a & 0x0040L)
#define adPrimsHaveNormals(a) (a & 0x0080L)
#define adPrimsHaveOrientation(a) (a & 0x0400L)