AutoCAD 2012 DXF reference by Autodesk
“The DXF™ format is a tagged data representation of all the information contained in an AutoCAD® drawing file. Tagged data means that each data element in the file is preceded by an integer number that is called a group code. A group code's value indicates what type of data element follows. This value also indicates the meaning of a data element for a given object (or record) type. Virtually all user-specified information in a drawing file can be represented in DXF format.”
Object and Entity Codes
In the DXF™ format, the definition of objects differs from entities: objects have no graphical representation and entities do. For example, dictionaries are objects, and not entities.
Entities are also referred to as graphical objects while objects are referred to as nongraphical objects. Entities appear in both the BLOCK and ENTITIES sections of the DXF file. The use of group codes in the two sections is identical. Some group codes that define an entity always appear; others are optional and appear only if their values differ from the defaults. Do not write programs that rely on the order given here. The end of an entity is indicated by the next 0 group, which begins the next entity or indicates the end of the section.
HEADER Section
The HEADER section of a DXF file contains the settings of variables associated with the drawing. Each variable is specified by a 9 group code giving the variable's name, followed by groups that supply the variable's value.
CLASSES Section
The CLASSES section holds the information for application-defined classes whose instances appear in the BLOCKS, ENTITIES, and OBJECTS sections of the database. It is assumed that a class definition is permanently fixed in the class hierarchy. All fields are required.
TABLES Section
The TABLES section contains several tables, each of which can contain a variable number of entries.
The order of the tables may change, but the LTYPE table always precedes the LAYER table. Each table is introduced with a 0 group code with the label TABLE. This is followed by a 2 group code identifying the particular table (APPID, DIMSTYLE, LAYER, LTYPE, STYLE, UCS, VIEW, VPORT, or BLOCK_RECORD).
The tables in a drawing can contain deleted items, but these are not written to the DXF file. As a result, fewer table entries may follow the table header than are indicated by the 70 group code, so do not use the count in the 70 group code as an index to read in the table. This group code is provided so that a program that reads DXF files can allocate an array large enough to hold all the table entries that follow. Following this header for each table are the table entries. Each table entry consists of a 0 group identifying the item type (same as table name, such as LTYPE or LAYER), a 2 group giving the name of the table entry, a 70 group specifying flags relevant to the table entry (defined for each following table), and additional groups that give the value of the table entry. The end of each table is indicated by a 0 group with the value ENDTAB.
BLOCKS Section
The BLOCKS section contains an entry for each block reference in the drawing.
The BLOCKS section of the DXF file contains all the block definitions, including anonymous blocks generated by the HATCH command and by associative dimensioning. Each block definition contains the entities that make up that block as it is used in the drawing. The format of the entities in this section is identical to those in the ENTITIES section. All entities in the BLOCKS section appear between block and endblk entities.
External references are written in the DXF file as block definitions, except that they also include a string (group code 1) that specifies the path and file name of the external reference.
ENTITIES Section
This chapter presents the group codes that apply to graphical objects
NOTE : Do not write programs that rely on the order shown in these DXF code tables. Although these tables show the order of group codes as they usually appear, the order can change under certain conditions or may be changed in a future AutoCAD® release. The code that controls an entity should be driven by a case (switch) or a table so that it can process each group correctly even if the order is unexpected.
OBJECTS Section
This chapter presents the group codes that apply to nongraphical objects.
Objects are similar to entities, except that they have no graphical or geometric meaning. All objects that are not entities or symbol table records or symbol tables are stored in this section. This section represents a homogeneous heap of objects with topological ordering of objects by ownership, such that the owners always appear before the objects they own.
Drawing Interchange File Format
This appendix describes the various file formats AutoCAD® uses to interchange drawing data with other applications. The formats presented are Drawing Interchange File (DXF™), binary DXF, Slide (SLD), and the Slide Library (SLB) file formats.
DXF files can be either ASCII or binary format. Because ASCII DXF files are more common than the binary format, the term DXF file is used to refer to ASCII DXF files and the term binary DXF file is used for the binary format
ASCII DXF Files
This section describes the format of ASCII DXF files. It contains information that is needed only if you write your own programs to process DXF files or work with entity information obtained by AutoLISP® and ObjectARX® applications.
Essentially, a DXF file is composed of pairs of codes and associated values. The codes, known as group codes, indicate the type of value that follows. Using these group code and value pairs, a DXF file is organized into sections composed of records, which are composed of a group code and a data item. Each group code and value are on their own line in the DXF file.
Each section starts with a group code 0 followed by the string SECTION. This is followed by a group code 2 and a string indicating the name of the section (for example, HEADER). Each section is composed of group codes and values that define its elements. A section ends with a 0 followed by the string ENDSEC.
The overall organization of a DXF file is as follows:
- HEADER section. Contains general information about the drawing. It consists of an AutoCAD database version number and a number of system variables. Each parameter contains a variable name and its associated value.
- CLASSES section. Holds the information for application-defined classes, whose instances appear in the BLOCKS, ENTITIES, and OBJECTS sections of the database. A class definition is permanently fixed in class hierarchy.
- TABLES section. Contains definitions for the following symbol tables: APPID (application identification table) BLOCK_RECORD (block reference table) DIMSTYLE (dimension style table) LAYER (layer table) LTYPE (linetype table) STYLE (text style table) UCS (user coordinate system table) VIEW (view table) VPORT (viewport configuration table)
- BLOCKS section. Contains block definition and drawing entities that make up each block reference in the drawing.
- ENTITIES section. Contains the graphical objects (entities) in the drawing, including block references (insert entities).
- OBJECTS section. Contains the nongraphical objects in the drawing. All objects that are not entities or symbol table records or symbol tables are stored in this section. Examples of entries in the OBJECTS section are dictionaries that contain mline styles and groups.
- THUMBNAILIMAGE section. Contains the preview image data for the drawing. This section is optional.