1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
|
.. _Data Model:
Data Model
==========
.. _Database Objects:
Database Objects
----------------
(from the DXF Reference)
AutoCAD drawings consist largely of structured containers for database objects. Database
objects each have the following features:
- A handle whose value is unique to the drawing/DXF file, and is constant for the
lifetime of the drawing. This format has existed since AutoCAD Release 10, and as
of AutoCAD Release 13, handles are always enabled.
- An optional XDATA table, as entities have had since AutoCAD Release 11.
- An optional persistent reactor table.
- An optional ownership pointer to an extension dictionary which, in turn, owns
subobjects placed in it by an application.
Symbol tables and symbol table records are database objects and, thus, have a handle.
They can also have xdata and persistent reactors in their DXF records.
.. _DXF R12 Data Model:
DXF R12 Data Model
------------------
The DXF R12 data model is identical to the file structure:
- HEADER section: common settings for the DXF drawing
- TABLES section: definitions for LAYERS, LINETYPE, STYLES ....
- BLOCKS section: block definitions and its content
- ENTITIES section: modelspace and paperspace content
References are realized by simple names. The INSERT entity references the BLOCK definition
by the BLOCK name, a TEXT entity defines the associated STYLE and LAYER by its name and
so on, handles are not needed. Layout association of graphical entities in the ENTITIES
section by the paper_space tag :code:`(67, 0 or 1)`, 0 or missing tag means modelspace,
1 means paperspace. The content of BLOCK definitions is enclosed by the BLOCK and the
ENDBLK entity, no additional references are needed.
A clean and simple file structure and data model, which seems to be the reason why the
DXF R12 Reference (released 1992) is still a widely used file format and Autodesk/AutoCAD
supports the format by reading and writing DXF R12 files until today (DXF R13/R14 has no
writing support by AutoCAD!).
**TODO: list of available entities**
.. seealso::
More information about the DXF :ref:`File Structure`
.. _DXF R13+ Data Model:
DXF R13+ Data Model
-------------------
With the DXF R13 file format, handles are mandatory and they are really used for organizing
the new data structures introduced with DXF R13.
The HEADER section is still the same with just more available settings.
The new CLASSES section contains AutoCAD specific data, has to be written like AutoCAD
it does, but must not be understood.
The TABLES section got a new BLOCK_RECORD table - see :ref:`Block Management Structures`
for more information.
The BLOCKS sections is mostly the same, but with handles, owner tags and new ENTITY types.
Not active paperspace layouts store their content also in the BLOCKS section - see
:ref:`Layout Management Structures` for more information.
The ENTITIES section is also mostly same, but with handles, owner tags and new ENTITY types.
**TODO: list of new available entities**
And the new OBJECTS section - now its getting complicated!
Most information about the OBJECTS section is just guessed or gathered by trail and error,
because the documentation of the OBJECTS section and its objects in the DXF reference
provided by Autodesk is very shallow.
This is also the reason why I started the DXF Internals section, may be it helps other
developers to start one or two steps above level zero.
The OBJECTS sections stores all the non-graphical entities of the DXF drawing.
Non-graphical entities from now on just called 'DXF objects' to differentiate them from
graphical entities, just called 'entities'. The OBJECTS section follows commonly the
ENTITIES section, but this is not mandatory.
DXF R13 introduces several new DXF objects, which resides exclusive in the OBJECTS
section, taken from the DXF R14 reference, because I have no access to the DXF R13
reference, the DXF R13 reference is a compiled .hlp file which can't be read on Windows 10
or later, this a perfect example for not using closed (proprietary) data formats ;):
- DICTIONARY: a general structural entity as a <name: handle> container
- ACDBDICTIONARYWDFLT: a DICTIONARY with a default value
- DICTIONARYVAR: used by AutoCAD to store named values in the database
- ACAD_PROXY_OBJECT: proxy object for entities created by other applications than AutoCAD
- GROUP: groups graphical entities without the need of a BLOCK definition
- IDBUFFER: just a list of references to objects
- IMAGEDEF: IMAGE definition structure, required by the IMAGE entity
- IMAGEDEF_REACTOR: also required by the IMAGE entity
- LAYER_INDEX: container for LAYER names
- MLINESTYLE
- OBJECT_PTR
- RASTERVARIABLES
- SPATIAL_INDEX: is always written out empty to a DXF file. This object can be ignored.
- SPATIAL_FILTER
- SORTENTSTABLE: control for regeneration/redraw order of entities
- XRECORD: used to store and manage arbitrary data. This object is similar in concept
to XDATA but is not limited by size or order. Not supported by R13c0 through R13c3.
Still missing the LAYOUT object, which is mandatory in DXF R2000 to manage multiple
paperspace layouts. I don't know how DXF R13/R14 manages multiple layouts or if they
even support this feature, but I don't care much about DXF R13/R14, because AutoCAD has
no write support for this two formats anymore. Ezdxf tries to upgrade this two DXF
versions to DXF R2000 with the advantage of only two different data models to support:
DXF R12 and DXF R2000+
New objects introduced by DXF R2000:
- LAYOUT: management object for modelspace and multiple paperspace layouts
- ACDBPLACEHOLDER: surprise - just a place holder
New objects in DXF R2004:
- DIMASSOC
- LAYER_FILTER
- MATERIAL
- PLOTSETTINGS
- VBA_PROJECT
New objects in DXF R2007:
- DATATABLE
- FIELD
- LIGHTLIST
- RENDER
- RENDERENVIRONMENT
- MENTALRAYRENDERSETTINGS
- RENDERGLOBAL
- SECTION
- SUNSTUDY
- TABLESTYLE
- UNDERLAYDEFINITION
- VISUALSTYLE
- WIPEOUTVARIABLES
New objects in DXF R2013:
- GEODATA
New objects in DXF R2018:
- ACDBNAVISWORKSMODELDEF
Undocumented objects:
- SCALE
- ACDBSECTIONVIEWSTYLE
- FIELDLIST
.. _Object Organisation:
Objects Organisation
--------------------
Many objects in the OBJECTS section are organized in a tree-like structure of DICTIONARY
objects.
Starting point for this data structure is the 'root' DICTIONARY with several entries to
other DICTIONARY objects. The root DICTIONARY has to be the first object in the OBJECTS
section. The management dicts for GROUP and LAYOUT objects are really important, but
IMHO most of the other management tables are optional and for the most use cases not
necessary. Ezdxf creates only these entries in the root dict and most of them pointing
to an empty DICTIONARY:
- ACAD_COLOR: points to an empty DICTIONARY
- ACAD_GROUP: required
- ACAD_LAYOUT: required
- ACAD_MATERIAL: points to an empty DICTIONARY
- ACAD_MLEADERSTYLE: points to an empty DICTIONARY
- ACAD_MLINESTYLE: points to an empty DICTIONARY
- ACAD_PLOTSETTINGS: points to an empty DICTIONARY
- ACAD_PLOTSTYLENAME: required, points to ACDBDICTIONARYWDFLT with one entry: 'Normal'
- ACAD_SCALELIST: points to an empty DICTIONARY
- ACAD_TABLESTYLE: points to an empty DICTIONARY
- ACAD_VISUALSTYLE: points to an empty DICTIONARY
.. _Root DICTIONARY:
Root DICTIONARY content for DXF R2018
-------------------------------------
.. code-block:: none
0
SECTION
2 <<< start of the OBJECTS section
OBJECTS
0 <<< root DICTIONARY has to be the first object in the OBJECTS section
DICTIONARY
5 <<< handle
C
330 <<< owner tag
0 <<< always #0, has no owner
100
AcDbDictionary
281 <<< hard owner flag
1
3 <<< first entry
ACAD_CIP_PREVIOUS_PRODUCT_INFO
350 <<< handle to target (pointer)
78B <<< points to a XRECORD with product info about the creator application
3 <<< entry with unknown meaning, if I should guess: something with about colors ...
ACAD_COLOR
350
4FB <<< points to a DICTIONARY
3 <<< entry with unknown meaning
ACAD_DETAILVIEWSTYLE
350
7ED <<< points to a DICTIONARY
3 <<< GROUP management, mandatory in all DXF versions
ACAD_GROUP
350
4FC <<< points to a DICTIONARY
3 <<< LAYOUT management, mandatory if more than the *active* paperspace is used
ACAD_LAYOUT
350
4FD <<< points to a DICTIONARY
3 <<< MATERIAL management
ACAD_MATERIAL
350
4FE <<< points to a DICTIONARY
3 <<< MLEADERSTYLE management
ACAD_MLEADERSTYLE
350
4FF <<< points to a DICTIONARY
3 <<< MLINESTYLE management
ACAD_MLINESTYLE
350
500 <<< points to a DICTIONARY
3 <<< PLOTSETTINGS management
ACAD_PLOTSETTINGS
350
501 <<< points to a DICTIONARY
3 <<< plot style name management
ACAD_PLOTSTYLENAME
350
503 <<< points to a ACDBDICTIONARYWDFLT
3 <<< SCALE management
ACAD_SCALELIST
350
504 <<< points to a DICTIONARY
3 <<< entry with unknown meaning
ACAD_SECTIONVIEWSTYLE
350
7EB <<< points to a DICTIONARY
3 <<< TABLESTYLE management
ACAD_TABLESTYLE
350
505 <<< points to a DICTIONARY
3 <<< VISUALSTYLE management
ACAD_VISUALSTYLE
350
506 <<< points to a DICTIONARY
3 <<< entry with unknown meaning
ACDB_RECOMPOSE_DATA
350
7F3
3 <<< entry with unknown meaning
AcDbVariableDictionary
350
7AE <<< points to a DICTIONARY with handles to DICTIONARYVAR objects
0
DICTIONARY
...
...
0
ENDSEC
|