Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DXF Reference

Download as pdf or txt
Download as pdf or txt
You are on page 1of 59

DXF Reference

u12.1.02
Copyright © 1993 Autodesk, Inc.
All Rights Reserved

This publication, or parts thereof, may not be reproduced in any form, by any method, for any purpose.

AUTODESK, INC. MAKES NO WARRANTY, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY
IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, REGARDING THESE
MATERIALS AND MAKES SUCH MATERIALS AVAILABLE SOLELY ON AN “AS-IS” BASIS.

IN NO EVENT SHALL AUTODESK, INC. BE LIABLE TO ANYONE FOR SPECIAL, COLLATERAL, INCIDENTAL, OR
CONSEQUENTIAL DAMAGES IN CONNECTION WITH OR ARISING OUT OF PURCHASE OR USE OF THESE
MATERIALS. THE SOLE AND EXCLUSIVE LIABILITY TO AUTODESK, INC., REGARDLESS OF THE FORM OF ACTION,
SHALL NOT EXCEED THE PURCHASE PRICE OF THE MATERIALS DESCRIBED HEREIN.

For conditions of use and permission to use these materials for publication in other than the English language,
contact Autodesk, Inc.

Autodesk, Inc. reserves the right to revise and improve its products as it sees fit. This publication describes the
state of this product at the time of its publication, and may not reflect the product at all times in the future.

Autodesk Trademarks

The following are registered trademarks of Autodesk, Inc.: ADI, Advanced Modeling Extension, AME, ATC,
Autodesk, Autodesk Animator, the Autodesk logo, AutoCAD, AutoCAD Training Center, AutoLISP, AutoShade,
AutoSketch, AutoSolid, James Gleick’s CHAOS: The Software, Multimedia Explorer, and 3D Studio.

The following are trademarks of Autodesk, Inc.: ACAD, Advanced User Interface, Aemulus, AME Link, Animation
Partner, Animation Player, Animator Pro, Animator Pro Player, ATLAST, AUI, AutoCAD Development System,
AutoCAD Simulator, AutoCAD SQL Extension, AutoCAD SQL Interface, Autodesk 3D Concepts, Autodesk Animator
Clips, Autodesk Animator Theatre, Autodesk DesignExpert, Autodesk Device Interface, Autodesk
ManufactoringExpert, Autodesk Multimedia Training Center, Autodesk Software Developer’s Kit, Autodesk Training
Center, AutoFlix, AutoCDM, AutoEDM, AutoLathe, AutoMill, AutoSurf, ContourView, Cyberized, CyberParts, DXF,
FLI, Flic, Geodyssey, HyperChem, Office Layout, Office Series, SketchTools, SmartCursor, Syntage, Visual Link, 3D
Plan, and World-Creating Toolkit.

The following are service marks of Autodesk, Inc.: Autodesk Strategic Developer, Autodesk Strategic Developer
logo, Autodesk Registered Developer, Autodesk Registered Developer logo, and TinkerTech.

Third Party Trademarks

RenderMan is a registered trademark of Pixar used by Autodesk under license from Pixar.

All brand names, product names or trademarks belong to their respective holders.

GOVERNMENT USE

Use, duplication, or disclosure by the U. S. Government is subject to restrictions as set forth in FAR 52.227-19
(Commercial Computer Software-Restricted Rights) and DFAR 252.227-7013(c) (1) (ii) (Rights in Technical Data and
Computer Software), as applicable.

2
Table of Contents
Drawing Interchange File Formats ................................................................................................................ 4
ASCII Drawing Interchange (DXF) Files...................................................................................................... 4
DXF File Format ..................................................................................................................................... 4
General File Structure ........................................................................................................................... 4
Group Codes.......................................................................................................................................... 6
Comments ............................................................................................................................................. 8
File Sections .......................................................................................................................................... 9
HEADER Section .................................................................................................................................. 10
TABLES Section ........................................................................................................................................ 16
BLOCKS Section ................................................................................................................................... 19
ENTITIES Section ................................................................................................................................. 19
Entity Coordinate Systems (ECS) ......................................................................................................... 31
Arbitrary Axis Algorithm...................................................................................................................... 33
Extended Entity Data .............................................................................................................................. 33
Organization of Extended Entity Data................................................................................................. 35
Writing DXF Interface Programs ............................................................................................................. 37
Binary DXF Files ....................................................................................................................................... 40
Binary Drawing Interchange (DXB) Files ................................................................................................. 41
DXBIN Command................................................................................................................................. 41
DXB File format ................................................................................................................................... 41
Writing DXB Files ................................................................................................................................. 44
Appendix: DXF Group Code Summary ........................................................................................................ 45
Group Codes in Numerical Order............................................................................................................ 45
Group Codes by Entity ............................................................................................................................ 47
Entity Group Codes ............................................................................................................................. 48
Block and Table Group Codes ............................................................................................................. 54

3
Drawing Interchange File Formats
AutoCAD can be used as a complete drawing editor. However, in some applications,
other programs must examine AutoCAD drawings or generate drawings to be viewed,
modified, or plotted with AutoCAD. Drawing Interchange Format (DXF) files support the
interchange of drawings between AutoCAD and other programs. All implementations of
AutoCAD accept this format.

AutoCAD also supports the Initial Graphics Interchange Specification (IGES) file format.
The information comprising an AutoCAD drawing can be written out to an IGES format,
and IGES files can be read and converted to the AutoCAD internal format.

Note: We don’t recommend that you write programs to read .dwg files. The format of
this file can change significantly as new features are added to AutoCAD.

ASCII Drawing Interchange (DXF) Files


DXF files are standard ASCII text files. They can easily be translated to the formats of
other CAD systems or submitted to other programs for specialized analysis. AutoCAD
can also produce or read a binary form of the full DXF file.

DXF File Format


This section describes the format of a DXF file. It contains information needed only if
write your own programs to process DXF files or work with entity information obtained
by certain AutoLISP and ADS functions.

It might be helpful to produce a DXF file from a small drawing, print it out, and refer to it
while reading the information presented next.

General File Structure


A Drawing Interchange File is an ASCII text file with a file type of .dxf and specially
formatted text. The overall organization of a DXF file is as follows:

1. HEADER section—General information about the drawing is found in this section of


the DXF file. Each parameter has a variable name and an associated value (see
Header Section).

2. TABLES section—This section contains definitions of named items.

• Linetype table (LTYPE)


• Layer table (LAYER)
• Text Style table (STYLE)
• View table (VIEW)
• User Coordinate System table (UCS)

4
• Viewport Configuration table (VPORT)
• Dimension Style table (DIMSTYLE)
• Application Identification table (APPID)

3. BLOCKS section—This section contains Block Definition entities describing the


entities that make up each Block in the drawing.

4. ENTITIES section—This section contains the drawing entities, including any Block
References.

5. END OF FILE

If you use DXFOUT’s Entities option, the resulting DXF file contains only the ENTITIES
section and the END OF FILE marker, and the ENTITIES section reflects only the objects
you select for output.

Note: If you select an INSERT entity, the corresponding Block definition is not included in
the output file.

A DXF file is composed of many groups, each of which occupies two lines in the DXF file.
The first line of a group is a group code, which is a positive nonzero integer output in
FORTRAN 13—this is, right-justified and blank filled in a three-character field (the
exception to this is the four-digit extended entity data group codes, which are output in
FORTRAN 14). The second line of the group is the group value, in a format that depends
on the type of group specified by the group code. Although DXFOUT output has a fixed
format, the DXFIN format is free.

The specific assignment of group codes depends on the item described in the file.
However, the type of the value this group supplies is derived from the group code in the
following way:
Table 1. Group code ranges

Group code range Following value Group code range Following value

0-9 String 210-239 Floating-point

10-59 Floating-point 999 Command (string)

60-79 Integer 1000-1009 String

140-147 Floating-point 1010-1059 Floating-point

170-175 Integer 1060-1079 Integer

5
A program can read the value following a group code without knowing the particular
use of this group in an item in the file. The appearance of values in the DXF file is not
affected by the setting of the UNITS command, coordinates are represented as decimal
(or possibly scientific notation if very large) numbers, and angles are represented in
decimal degrees with zero degrees to the east of origin.

Variables, table entries, and entities are described by a group that introduces the item,
giving its type and/or name, followed by multiple groups that supply the values
associated with the item. In addition, special groups are used for file separators such as
markers for the beginning and end of sections, tables, and the file itself.

Entities, table entries, and file separators are introduced with a 0 group code that is
followed by a name describing the item.

Note: The maximum DXF file string length is 256 characters. If your AutoCAD drawing
contains strings that exceed this number, those strings are truncated during DXFOUT. If
your DXF file contains strings that exceed this number, DXFIN fails.

Group Codes
Group codes are used to indicate the type of the value of the group, and to indicate the
general use of the group. The specific function of the group code depends on the actual
variable, table item, or entity description. This section indicates the general use of
groups, noting as “(fixed)” any that always have the same function.
Table 2. AutoCAD entity group codes (by number)

Group code Value type

0 Identifies the start of an entity, table entry, or file separator. The type of entity is
given by the text value that follows this group
.
1 The primary text value of an entity
2 A name Attribute tag, Block name, and so on. Also used to identify a DXF section or
table name
3–4 Other textual or name values
5 Entity handle expressed as a hexadecimal string (fixed)
6 Linetype name (fixed)
7 Text style name (fixed)
8 Layer name (fixed)
9 Variable name identifier (used only in HEADER section of the DXF file)
10 Primary X coordinate (start point of a Line or Text entity, center of a Circle, etc.)
11–18 Other X coordinates

6
Table 3. AutoCAD entity group codes (by number) (continued)

Group code Value type

20 Primary Y coordinate. 2n values always correspond to 1n values and immediately


follow them in the file
21–28 Other Y coordinates
30 Primary Z coordinate. 3n values always correspond to 1n and 2n values and
immediately follow them in the file
31–37 Other Z coordinates
38 This entity’s elevation if nonzero (fixed). Exists only in output from versions prior to
R11
39 This entity’s thickness if nonzero (fixed)
40–48 Floating-point values (text height, scale factors, etc.)
49 Repeated value—multiple 49 groups may appear in one entity for variable length
tables (such as the dash lengths in the LTYPE table). A 7x group always appears
before the first 49 group to specify the table length
50–58 Angles
62 Color number (fixed)
66 “Entities follow” flag (fixed)
67 Identifies whether entity is in model space or paper space
68 Identifies whether viewport is on but fully off screen, is not active, or is off
69 Viewport identification number
70–78 Integer values such as repeat counts, flag bits, or modes
210, X, Y, and Z components of extrusion direction (fixed)
220,
230
999 Comments
1000 An ASCII string (up to 255 bytes long) in extended entity data
1001 Registered application name (ASCII string up to 31 bytes long) for extended entity
data (fixed)
1002 Extended entity data control string (“{“ or “}”); (fixed)
1003 Extended entity data Layer name
1004 Chunk of bytes (up to 127 bytes long) in extended entity data
1005 Extended entity data database handle

7
Table 4. AutoCAD entity group codes (by number) (continued)

Group code Value type

1010, Extended entity data X, Y, and Z coordinates


1020,
1030
1011, Extended entity data X, Y, and Z coordinates of 3D world space position
1021,
1031
1012, Extended entity data X, Y, and Z components of 3D world space displacement
1022,
1032
1013, Extended entity data X, Y, and Z components of 3D world space direction
1023,
1033
1040 Extended entity data Floating-point value
1041 Extended entity data distance value
1042 Extended entity data scale factor
1070 Extended entity data 16-bit signed integer
1071 Extended entity data 32-bit long

Comments
The 999 group code indicates that the following line is a comment string. DXFOUT does
not include such groups in a DXF output file, but DXFIN honors them and ignores the
comments. You can use the 999 group to include comments in a DXF file you’ve edited.
For example:
999
This is a comment.
999
This is another comment.

8
File Sections
The DXF file is subdivided into four editable sections, plus the END OF FILE marker. File
separator groups are used to delimit these file sections. The following is an example of a
void DXF file with only the section markers and table headers present:

0 (Begin HEADER section)


SECTION
2
HEADER
<<<<Header variable items go here>>>>
0
ENDSEC (End HEADER section)
0 (Begin TABLES section)
SECTION
2
TABLES
0
TABLE
2
VPORT
70
(viewport table maximum item count)
<<<<viewport table items go here>>>>
0
ENDTAB
0
TABLE
2
APPID, DIMSTYLE, LTYPE, LAYER, STYLE, UCS, VIEW, or VPORT
70
(Table maximum item count)
<<<<Table items go here>>>>
0
ENDTAB
0
ENDSEC (End TABLES section)
0 (Begin BLOCKS section)
SECTION
2
BLOCKS
<<<<Block definition entries go here>>>>
0
ENDSEC (End BLOCKS section)
0 (Begin ENTITIES section)
SECTION
2

9
ENTITITES
<<<<Drawing entities go here>>>>
0
ENDSEC (End ENTITIES section)
0
EOF (End of file)

HEADER Section
The HEADER section of the DXF file contains settings of variables associated with the
drawing. Each variable is specified in the header section by a 9 group giving the
variable’s name, followed by groups that supply the variable’s value. The following list
shows the header variables and their meanings.

Although this list is similar to the list of system variables in the AutoCAD Command
Reference, the two lists are not identical. Be sure to refer to the proper list.

Note: $AXISMODE and $AXISUNIT are no longer functional in Release 12.


Table 5. DXF system variables

Variable Type Description

$ACADVER 1 The AutoCAD drawing database version number;


AC1006 = R10, AC1009 = R11 and R12
$ANGBASE 50 Angle 0 direction
$ANGDIR 70 1 = clockwise angles, 0 = counterclockwise angles
$ATTDIA 70 Attribute entry dialogs; 1 = on, 0 = off
$ATTMODE 70 Attribute visibility; 0 = none, 1 = normal, 2 = all
$ATTREQ 70 Attribute prompting during INSERT; 1 = on, 0 = off
$AUNITS 70 Units format for angles
$AUPREC 70 Units precision for angles
$AXISMODE 70 Axis on if nonzero (not functional in Release 12)
$AXISUNIT 10, 20 Axis X and Y tick spacing (not functional in Release 12)
$BLIPMODE 70 Blip mode on if nonzero
$CECOLOR 62 Entity color number; 0 = BYBLOCK, 256 = BYLAYER
$CELTYPE 6 Entity linetype name, or BYBLOCK or BYLAYER
$CHAMFERA 40 First chamfer distance
$CHAMFERB 40 Second chamfer distance
$CLAYER 8 Current layer name

10
Table 6. DXF system variables (continued)

Variable Type Description

$COORDS 70 0 = static coordinate display, 1 = continuous update, 2 =


“d<a” format
$DIMALT 70 Alternate unit dimensioning performed if nonzero
$DIMALTD 70 Alternate unit decimal places
$DIMALTF 40 Alternate unit scale factor
$DIMAPOST 1 Alternate dimensioning suffix
$DIMASO 70 1 = create associative dimensioning, 0 = draw individual
entities
$DIMASZ 40 Dimensioning arrow size
$DIMBLK 2 Arrow block name
$DIMBLK1 1 First arrow block name
$DIMBLK2 1 Second arrow block name
$DIMCEN 40 Size of center mark/lines
$DIMCLRD 70 Dimension line color, range is 0 = BYBLOCK, 256 =
BYLAYER
$DIMCLRE 70 Dimension extension line color, range is 0 = BYBLOCK, 256
= BYLAYER
$DIMCLRT 70 Dimension text color, range is 0 = BYBLOCK, 256 =
BYLAYER
$DIMDLE 40 Dimension line extension
$DIMDLI 40 Dimension line increment
$DIMEXE 40 Extension line extension
$DIMEXO 40 Extension line offset
$DIMGAP 40 Dimension line gap
$DIMLFAC 40 Linear measurements scale factor
$DIMLIM 70 Dimension limits generated if nonzero
$DIMPOST 1 General dimensioning suffix
$DIMRND 40 Rounding value for dimension distances
$DIMSAH 70 Use separate arrow blocks if nonzero
$DIMSCALE 40 Overall dimensioning scale factor
$DIMSE1 70 First extension line suppressed if nonzero

11
Table 7. DXF system variables (continued)

Variable Type Description

$DIMSE2 70 Second extension line suppressed if nonzero


$DIMSHO 70 1 = recompute dimensions while dragging, 0 = drag
original image
$DIMSOXD 70 Suppress outside-extensions dimension lines if nonzero
$DIMSTYLE 2 Dimension style name
$DIMTAD 70 Text above dimension line if nonzero
$DIMTFAC 40 Dimension tolerance display scale factor
$DIMTIH 70 Text inside horizontal if nonzero
$DIMTIX 70 Force text inside extensions if nonzero
$DIMTIM 40 Minus tolerance
$DIMTOFL 70 If text outside extensions, force line extensions between
extensions if nonzero
$DIMTOH 70 Text outside horizontal if nonzero
$DIMTOL 70 Dimension tolerances generated if nonzero
$DIMTP 40 Plus tolerance
$DIMTSZ 40 Dimensioning tick size; 0 = no ticks
$DIMTVP 40 Text vertical position
$DIMTXT 40 Dimensioning text height
$DIMZIN 70 Zero suppression for “feet & inch” dimensions
$DWGCODEPAGE 3 Drawing code page. Set to the system code page when a
new drawing is created, but not otherwise maintained by
AutoCAD
$DRAGMODE 70 0 = off, 1 = on, 2 = auto
$ELEVATION 40 Current elevation set by ELEV command
$EXTMAX 10, 20, 30 X, Y, and Z drawing extents upper-right corner (in WCS)
$EXTMIN 10, 20, 30 X, Y, and Z drawing extents lower-left corner (in WCS)
$FILLETRAD 40 Fillet radius
$FILLMODE 70 Fill mode on if nonzero
$HANDLING 70 Handles enabled if nonzero
$HANDSEED 5 Next available handle
$INSBASE 10, 20, 30 Insertion base set by BASE command (in WCS)

12
Table 8. DXF system variables (continued)

Variable Type Description

$LIMCHECK 70 Nonzero if limits checking is on


$LIMMAX 10, 20 XY drawing limits upper-right corner (in WCS)
$LIMMIN 10, 20 XY drawing limits lower-left corner (in WCS)
$LTSCALE 40 Global linetype scale
$LUNITS 70 Units format for coordinates and distances
$LUPREC 70 Units precision for coordinates and distances
$MAXACTVP 70 Sets maximum number of viewports to be regenerated
$MENU 1 Name of menu file
$MIRRTEXT 70 Mirror text if nonzero
$ORTHOMODE 70 Ortho mode on if nonzero
$OSMODE 70 Running object snap modes
$PDMODE 70 Point display mode
$PDSIZE 40 Point display size
$PELEVATION 40 Current paper space elevation
$PEXTMAX 10, 20, 30 Maximum X, Y, and Z extents for paper space
$PEXTMIN 10, 20, 30 Minimum X, Y, and Z extents for paper space
$PLIMCHECK 70 Limits checking in paper space when nonzero
$PLIMMAX 10, 20 Maximum X and Y limits in paper space
$PLIMMIN 10, 20 Minimum X and Y limits in paper space
$PLINEGEN 70 Governs the generation of linetype patterns around the
vertices of a 2D Polyline
1 = linetype is generated in a continuous pattern around
vertices of the Polyline
0 = each segment of the Polyline starts and ends with a
dash
$PLINEWID 40 Default Polyline width
$PSLTSCALE 70 Controls paper space linetype scaling
1 = no special linetype scaling
0 = viewport scaling governs linetype scaling
$PUCSNAME 2 Current paper space UCS name
$PUCSORG 10, 20, 30 Current paper space UCS origin
$PUCSXDIR 10, 20, 30 Current paper space UCS X axis

13
Table 9. DXF system variables (continued)

Variable Type Description

$PUCSYDIR 10, 20, 30 Current paper space UCS Y axis


$QTEXTMODE 70 Quick text mode on if nonzero
$REGENMODE 70 REGENAUTO mode on if nonzero
$SHADEDGE 70 0 = faces shaded, edges not highlighted
1 = faces shaded, edges highlighted in black
2 = faces not filled, edges in entity color
3 = faces in entity color, edges in black
$SHADEDIF 70 Percent ambient/diffuse light, range 1–100, default 70
$SKETCHINC 40 Sketch record increment
$SKPOLY 70 0 = sketch lines, 1 = sketch polylines
$SPLFRAME 70 Spline control polygon display; 1 = on, 0 = off
$SPLINESEGS 70 Number of line segments per spline patch
$SPLINETYPE 70 Spline curve type for PEDIT Spline
$SURFTAB1 70 Number of mesh tabulations in first direction
$SURFTAB2 70 Number of mesh tabulations in second direction
$SURFTYPE 70 Surface type for PEDIT Smooth
$SURFU 70 Surface density (for PEDIT Smooth) in M direction
$SURFV 70 Surface density (for PEDIT Smooth) in N direction
$TDCREATE 40 Date/time of drawing creation
$TDINDWG 40 Cumulative editing time for this drawing
$TDUPDATE 40 Date/time of last drawing update
$TDUSRTIMER 40 User elapsed timer
$TEXTSIZE 40 Default text height
$TEXTSTYLE 7 Current text style name
$THICKNESS 40 Current thickness set by ELEV command
$TILEMODE 70 1 for previous release compatibility mode, 0 otherwise
$TRACEWID 40 Default Trace width
$UCSNAME 2 Name of current UCS
$UCSORG 10, 20, 30 Origin of current UCS (in WCS)
$UCSXDIR 10, 20, 30 Direction of current UCS’s X axis (in WCS)
$UCSYDIR 10, 20, 30 Direction of current UCS’s Y axis (in WCS)

14
Table 10. DXF system variables (continued)

Variable Type Description

$UNITMODE 70 Low bit set = display fractions, feet-and-inches, and


surveyor’s angles in input format
$USERI1 – 5 70 For integer variables intended for use by third-party
developers
$USERR1 – 5 40 Five real variables intended for use by third-party
developers
$USRTIMER 70 0 = timer off, 1 = timer on
$VISRETAIN 70 0 = don’t retain Xref-dependent visibility settings
1 = retain Xref-dependent visibility settings
$WORLDVIEW 70 1 = set UCS to WCS during DVIEW/VPOINT
0 = don’t change UCS

The following header variables existed prior to AutoCAD Release 11 but now have
independent settings for each active viewport. DXFIN honors these variables when read
from DXF files, but if a VPORT symbol table with *ACTIVE entries is present (as is true for
any DXF file produced by Release 11 or higher), the values in the VPORT table entries
override the values of these header variables.
Table 11. Revised VPORT header variables

Variable Type Description

$FASTZOOM 70 Fast zoom enabled if nonzero


$GRIDMODE 70 Grid mode on if nonzero
$GRIDUNIT 10, 20 Grid X and Y spacing
$SNAPANG 50 Snap grid rotation angle
$SNAPBASE 10, 20 Snap/grid base point (in UCS)
$SNAPISOPAIR 70 Isometric plane; 0 = left, 1 = top. 2 = right
$SNAPMODE 70 Snap mode on if nonzero
$SNAPSTYLE 70 Snap style; 0 = standard, 1 = isometric
$SNAPUNIT 10, 20 Snap grid X and Y spacing
$VIEWCTR 10, 20 XY center of current view on screen
$VIEWDIR 10, 20, 30 Viewing direction (direction from target, in WCS)
$VIEWSIZE 40 Height of view

15
The date/time variables ($TDCREATE and $TDUPDATE) are output as real numbers in the
following format:
<Julian date>.<Fraction>

The elapsed time variables ($TDINDWG and $TDUSRTIMER) have a similar format:
<Number of days>.<Fraction>

The date and time variables are described in the AutoCAD Command Reference.

TABLES Section
The TABLES section contains several tables, each of which contains 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 with the label TABLE. This is followed by a
2 group identifying the particular table (VPORT, LTYPE, LAYER, STYLE, VIEW, DIMSTYLE,
UCS, or APPID) and a 70 group that specifies the maximum number of table entries that
may follow. Table names are output in uppercase characters.

The tables in a drawing can contain deleted items, but these are not written to the DXF
file. Thus, fewer table entries may follow the table header that are indicated by the 70
group, so don’t use the count in 70 group as an index to read in the table. This group is
provided so 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 item consists of a 0
group identifying the item type (same as table name, e.g., 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.

The 70 group flag bit values are described in the following chart. Additional 70 group
values that apply to LAYER, STYLE, and VIEW table entries are described in the following
sections.
Table 12. Group 70 bit codes that apply to all table entries

Flag bit value Meaning

16 If set, table entry is externally dependent on an Xref


32 If this bit and bit 16 are both set, the externally dependent Xref has been
successfully resolved
64 If set, the table entry was referenced by at least one entity in the drawing the last
time the drawing was edited. (This flag is for the benefit of AutoCAD commands; it
can be ignored by most programs that read DXF files, and need not be set by
programs that write DXF files.)

16
The following are the groups used for each type of table item. All groups are present for
each table item.

APPID 2 (user-supplied application name), 70 (standard flag values).


These table entries maintain a set of names for all applications registered with a
drawing.
DIMSTYLE 2 (dimension style name), 70 (standard flag values), and the following, described by
dimension variable name: 3 (dimpost), 4 (dimapost), 5 (dimblk), 6 (dimblk1), 7
(dimblk2), 40 (dimscale), 41 (dimasz), 42 (dimexo), 43 (dimdli), 44 (dimexe), 45
(dimrnd), 46 (dimdle), 47 (dimtp), 48 (dimtm), 140 (dimtxt), 141 (dimcen), 142
(dimtsz), 143 (dimaltf), 144 (dimlfac), 145 (dimtvp), 146 (dimtfac), 147 (dimgap), 71
(dimtol), 72 (dimlim), 73 (dimtih), 74 (dimtoh), 75 (dimse1), 76 (dimse2), 77 (dimtad),
78 (dimzin), 170 (dimalt), 171 (dimaltd), 172 (dimtofl), 173 (dimsah), 174 (dimtix), 175
(dimsoxd), 176 (dimclrd), 177 (dimclre), 178 (dimclrt).
LTYPE 2 (linetype name), 70 (standard flag values), 3 (descriptive text for linetype), 72
(alignment code; value is always 65, the ASCII code for ‘A’), 73 (number of dash length
items), 40 (total pattern length), and optionally: 49 (dash length 1), 49 (dash length
2), and so on.
LAYER 2 (layer name), 70 (standard flag values), 62 (color number, negative if layer is off), 6
(linetype name).
In addition to the standard flags, the 70 group flag is bit coded as follows:

Table 13. Group 70 bit codes for LAYER table

Flag bit Meaning


value

1 If set, layer is frozen


2 If set, layer is frozen by default in new Viewports
4 If set, layer is locked

If no value (0) is set, the layer is on and thawed. The fourth bit (8) and the eighth bit
(128) are not used.

Xref-dependent layers are output during DXFOUT. For these layers, the associated
linetype name in the DXF file is always CONTINUOUS.
STYLE 2 (style name), 70 (standard flag values), 40 (fixed text height; 0 if not fixed), 41
(width factor), 50 (oblique angle), 71 (text generation flags), 42 (last height used), 3
(primary font filename), 4 (big-font file name; blank if none).

If the third bit (4) is set in the 70 group flags, the text style is vertically oriented.

17
A STYLE table item is also used to record shape file LOAD requests. In this case, the
first bit (1) is set in the 70 group flags and only the 3 group (shape filename) is
meaningful (all the other groups are output, however).

The text generation flags are a bit-coded field with the following bit meanings:
Table 14. Group 71 bit codes for STYLE table

Flag bit Meaning


value

2 Text is backward (mirrored in X)


4 Text is upside down (mirrored in Y)

UCS 2 (UCS name), 70 (standard flag values), 10, 20, 30 (origin), 11, 21, 31 (X axis
direction), 12 22, 32 (Y axis direction). All in World coordinates.
VIEW 2 (view name), 70 (standard flag values), 40 and 41 (view height and width, in DCS),
10 and 20 (view center point, in DCS), 11, 21, 31 (view direction from target, in WCS),
12, 22, 32 (target point, in WCS), 42 (lens length), 43 and 44 (front and back clipping
planes—offsets from target point), 50 (twist angle), 71 view mode (see VIEWMODE
system variable).

If the first bit (1) is set in the 70 group flags, this is a paper space view.
VPORT 2 (viewport name), 70 (standard flag values), 10 and 20 (lower-left corner of
viewport; 0.0 to 1.0), 11 and 21 (upper-right corner), 12 and 22 (view center point, in
DCS), 13 and 23 (snap base point), 14 and 24 (snap spacing, X and Y), 15 and 25 (grid
spacing, X and Y), 16, 26, 36 (view direction from target point), 17, 27, and 37 (view
target point), 40 (view height), 41 (viewport aspect ratio), 42 (lens length), 43 and 44
(front and back clipping planes; offsets from target point), 50 (snap rotation angle),
51 (view twist angle), 68 (status field, never saved), 69 (ID, never saved), 71 (view
mode; see VIEWMODE system variable), 72 (circle zoom percent), 73 (fast zoom
setting), 74 (UCSICON setting), 75 (snap on/off), 76 (grid on/off), 77 (snap style), 78
(snap isopair).

The VPORT table is unique in that it may contain several entries with the same name
(indicating a multiple-viewport configuration). The entries corresponding to the
active viewport configuration all have the name *ACTIVE. The first such entry
describes the current viewport.

18
BLOCKS Section
The BLOCKS section of the DXF file contains all the Block Definitions. It contains the
entities that make up the Blocks used in the drawing, including anonymous Blocks
generated by the HATCH command and by associative dimensioning. 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. Block and Endblk entities
appear only in the BLOCKS section. Block definitions are never nested (that is, no Block
or Endblk entity ever appears within another Block-Endblk pair), although a Block
definition can contain an Insert entity.

External References are written in the DXF file as any Block Definition, except they also
include a text string (group code 1) of the path and filename of the External Reference.
This is the text string format:

Xref filename

ENTITIES Section
Entity items appear in the BLOCKS and ENTITIES sections of the DXF file. The appearance
of entities in the two sections is identical.

Some groups that define an entity always appear; others are optional and appear only if
they differ from their default values. In the following description, groups that always
occur are given by their group number and function, while optional groups are indicated
by “-optional N” following the group description. N is the default value if the group is
omitted.

Programs that read DXF files should not assume that the groups describing an entity
occur in the order given here. The end of an entity is indicated by the next 0 group,
beginning the next entity or indicating the end of the section.

Note: As AutoCAD is further enhanced, new groups will be added to entities to


accommodate additional features. Accommodating DXF files for future releases of
AutoCAD will be easier if you write your DXF processing program in a table-driven way,
ignore undefined groups, and make no assumptions about the order of groups in an
entity.

Each entity begins with a 0 group identifying the entity type. Every entity contains an 8
group that gives the name of the layer on which the entity resides. Each entity may have
elevation, thickness, linetype, or color information associated with it.

If handles are enabled, every entity has a 5 group containing its handle (as a string
representing a hexadecimal number).

The following groups are included only if the entity has nondefault values for these
properties. When a group is omitted, its default value upon input (when using DXFIN) is
indicated in the third column. If the value of a group is equal to the default, it is omitted
upon output (when using DXFOUT).

19
Table 15. Group codes common to all entities

Group code Meaning If omitted,


defaults to…

6 Linetype name (if not BYLAYER). The special name BYLAYER


BYBLOCK indicates a floating linetype
38 Elevation (if nonzero). Exists only in output from versions 0
prior to R11. Otherwise, Z coordinates are supplied as 3x-
groups as part of each of the entity’s defining points
39 Thickness (if nonzero) 0
62 Color number (if not BYLAYER). Zero indicates the BYLAYER
BYBLOCK (floating) color. 256 indicates the BYLAYER color
67 Absent or zero indicates entity is in model space. One 0
indicates entity is in paper space, other values are
reserved
210, These groups are included for each Line, Point, Circle, 0,0,1
220, Shape, Text, Arc, Trace, Solid, Block Reference, Polyline,
230 Dimension, Attribute, and Attribute Definition entity if its
extrusion direction is not parallel to the World Z axis.
They indicate the X, Y, and Z components of the entity’s
extrusion direction

The rest of the groups that make up an entity item are described next. Many of the
entities include “flag” groups. These are integer codes (6x or 7x groups) that encode
information specific to the particular entity type. In the following descriptions, the term
bit-coded means that the flag contains various true/false values coded as the sum of the
bit values given. Any bits not defined in the following should be ignored in these fields
and set to zero when constructing a DXF file.

LINE 10, 20, 30 (start point), 11, 21, 31 (endpoint).


POINT 10, 20, 30 (point).

Point entities have an optional 50 group that determines the orientation of PDMODE
images. The group value is the negative of the Entity Coordinate Systems (ECS) angle
of the UCS X axis in effect when the point was drawn. The X axis of the UCS in effect
when the point was drawn is always parallel to the XY plane for the point’s ECS, and
the angle between the UCS X axis and the ECS X axis is a single 2D angle. The value in
group 50 is the angle from horizontal (the effective X axis) to the ECS X axis. Entity
Coordinate Systems (ECS) are described later in this section.
CIRCLE 10, 20, 30 (center), 40 (radius).
ARC 10, 20, 30 (center), 40 (radius), 50 (start angle), 51 (end angle).

20
TRACE Four points defining the corners of the trace: (10, 20, 30), (11, 21, 31), (12, 22, 32),
and (13, 23, 33).
SOLID Four points defining the corners of the solid: (10, 20, 30), (11, 21, 31), (12, 22, 32),
and (13, 23, 33). If only three points were entered (forming a triangular solid), the
third and fourth points will be the same.
TEXT 10, 20, 30 (insertion point), 40 (height), 1 (text value), 50 (rotation angle -optional 0),
41 (relative X-scale factor -optional 1), 51 (oblique angle -optional 0), 7 (text style
name -optional STANDARD), 71 (text generation flags -optional 0), 72 (horizontal
justification type -optional 0), 73 (vertical justification type -optional 0), 11, 21, 31
(alignment point -optional, appears only if 72 or 73 group is present and nonzero).

The “text generation flags” are a bit-coded field with meanings as follows:
Table 16. Group 71 bit codes for Text entity

Flag bit Meaning


value

2 Text is backward (mirrored in X)


4 Text is upside down (mirrored in Y)

The justification-type value (group codes 72 and 73, not bit-coded) indicates the text-
justification style used on the text, as shown in the following table:
Table 17. Group 72 & 73 bit codes for Text entity

Group 73 Group 72 (horizontal alignment)


(vertical
alignment) 0 1 2 3 4 5

3 (Top) TLeft TCenter TRight


2 (Middle) MLeft MCenter MRight
1 (Bottom) BLeft BCenter BRight
0 (Baseline) Left Center Right Aligned Middle Fit

If the justification is anything other than baseline/left (groups 72 and 73 both 0),
group codes 11, 21, and 31 specify the alignment point (or the second alignment
point for Align or Fit).

DXFOUT handles ASCII control characters in text strings by expanding the character
into a ^ (caret) followed by the appropriate letter. For example, an ASCII Control-G
(BEL, decimal code 7) is output as ^G. If the text itself contains a caret character, it is
expanded to ^ (caret, space). DXFIN performs the complementary conversion.
SHAPE 10, 20, 30 (insertion point), 40 (size), 2 (shape name), 50 (rotation angle -optional 0),
41 (relative X-scale factor -optional 1), 51 (oblique angle -optional 0).

21
BLOCK 2 (Block name), 3 (this is also the Block name), 70 (Block type flag), 10, 20, 30 (Block
base point), and if the Block is an Xref Block it will also contain group code 1 (Xref
pathname). Block entities appear only in the BLOCKS section, not in the ENTITIES
section. The “Block type flag” (group 70) is bit-coded, with the following bit meanings:
Table 18. Group 70 bit codes for Block table

Flag bit Meaning


value

1 This is an anonymous Block generated by hatching, associative


dimensioning, other internal operations, or an application
2 This Block has Attributes
4 This Block is an external reference (Xref)
8 not used
16 This Block is externally dependent
32 This is a resolved external reference, or dependent of an external
reference
64 This definition is referenced

ENDBLK No groups. Appears only in the BLOCKS section.


INSERT 66 (Attributes follow flag -optional 0), 2 (Block name), 10, 20, 30 (insertion point), 41
(X-scale factor -optional 1), 42 (Y-scale factor -optional 1), 43 (Z-scale factor -optional
1), 50 (rotation angle -optional 0), 70 and 71 (column and row counts -optional 1), 44
and 45 (column and row spacing -optional 0).

If the value of the “Attributes follow flag” is 1, a series of Attribute (ATTRIB) entities is
expected to follow the Insert, terminated by a sequence end (SEQEND) entity.
ATTDEF 10, 20, 30 (text start), 40 (text height), 1 (default value, see TEXT for handling of ASCII
control characters), 3 (prompt string), 2 (tag string), 70 (Attribute flags), 73 (field
length -optional 0), 50 (text rotation -optional 0), 41 (relative X-scale factor -optional
1), 51 (oblique angle -optional 0), 7 (text style name -optional STANDARD), 71 (text
generation flags -optional 0, see TEXT for more information), 72 (horizontal text
justification type -optional 0, see TEXT for more information), 74 (vertical text
justification type -optional 0, see group 73 in TEXT for more information), 11, 21, 31
(alignment point -optional, appears only if 72 or 74 group is present and nonzero).

The “Attribute flags” (group code 70) are a bit-coded field in which the bits have the
following meanings:

22
Table 19. Group 70 bit codes for Attdef entity

Flag bit Meaning


value

1 Attribute is invisible (does not display)


2 This is a constant Attribute
4 Verification is required on input of this Attribute
8 Attribute is preset (no prompt during insertion)

ATTRIB 10,20,30 (text start), 40 (text height), 1 (value, see TEXT for more information for
handling ASCII control characters), 2 (Attribute tag), 70 (Attribute flags; see ATTDEF
for more information), 73 (field length -optional 0), 50 (text rotation -optional 0), 41
(relative X-scale factor -optional 1), 51 (oblique angle -optional 0), 7 (text style name -
optional STANDARD), 71 (text generation flags -optional 0, see TEXT for more
information), 72 (horizontal text justification type -optional 0, see TEXT for more
information), 74 (vertical text justification type -optional 0, see group 73 in TEXT for
more information), 11, 21, 31 (alignment point -optional, appears only if 72 or 74
group is present and nonzero).
POLYLINE 66 (vertices follow flag), 10, 20, 30 (polyline elevation—30 supplies elevation, 10 and
20 are always set to zero), 70 (Polyline flag -optional 0), 40 (default starting width -
optional 0), 41 (default ending width -optional 0), 71 and 72 (polygon mesh M and N
vertex counts -optional 0), 73 and 74 (smooth surface M and N densities -optional 0),
75 (curves and smooth surface type -optional 0). The default widths apply to any
vertex that doesn’t supply widths.

The “vertices follow flag” is always 1, indicating that a series of Vertex entities is
expected to follow the Polyline, terminated by a sequence end (SEQEND) entity. The
polyline flag (group code 70) is a bit-coded field with bits defined as follows:
Table 20. Group 70 bit codes for Polyline entity

Flag bit Meaning


value

1 This is closed Polyline (or a polygon mesh closed in the M direction)


2 Curve-fit vertices have been added
4 Spline-fit vertices have been added
8 This is a 3D Polyline
16 This is a 3D polygon mesh.
Group 75 indicates the smooth surface type as follows:
0 = no smooth surface fitted

23
5 = quadratic B-spline surface
6 = cubic B-spline surface
8 = Bezier surface
32 The polygon mesh is closed in the N direction
64 The Polyline is a polyface mesh
128 The linetype pattern is generated continuously around the vertices
of this Polyline

A polyface mesh is represented in DXF as a variant of a Polyline entity. The Polyline


header is identified as introducing a polyline mesh by the presence of the 64 bit in the
Polyline flags (70) group. The 71 group specifies the number of vertices in the mesh,
and the 72 group, the number of faces. While these counts are correct for all meshes
created with the PFACE command, applications are not required to place correct
values in these fields.

Following the Polyline header is a sequence of Vertex entities that specify the vertex
coordinates and faces that compose the mesh.

The AutoCAD entity structure imposes a limit on the number of vertices that a given
face entity can specify. You can represent more complex polygons by decomposing
them into triangular wedges. Their edges should be made invisible to prevent visible
artifacts of this subdivision from being drawn. The PFACE command performs this
subdivision automatically, but when applications generate polyface meshes directly,
the applications must do this themselves.

The number of vertices per face is the key parameter in this subdivision process. The
PFACEVMAX system variable provides an application with the number of vertices per
face entity. This value is read-only, and its set to 4.

Polyface meshes created with the PFACE command are always generated with all the
vertex coordinate entities first, followed by the definition entities. The code within
AutoCAD that processes polyface meshes does not require this ordering; it works
even with interleaved vertex coordinates and face dentitions as long as no face
specifies a vertex with an index that appears after it in the database. Programs that
read polyface meshes from DXF should be tolerant of odd vertex and face ordering.
VERTEX 10, 20, 30 (location), 40 (starting width -optional, see earlier), 41 (ending width -
optional, see earlier), 42 (bulge -optional 0), 70 (vertex flags -optional 0), 50 (curve fit
tangent direction -optional). The bulge is the tangent of 1/4 the included angle for an
arc segment, made negative if the arc goes clockwise from the start point to the
endpoint; a bulge of 0 indicates a straight segment, and a bulge of 1 is a semi-circle.

The meaning of the bit-coded Vertex flag (group code 70) is shown in the following
table:

24
Table 21. Group 70 bit codes for Vertex entity

Flag bit Meaning


value

1 Extra vertex created by curve-fitting


2 Curve-fit tangent defined for this vertex. A curve-fit tangent
direction of 0 may be omitted from the DXF output, but is
significant if this bit is set
4 Unused (never set in DXF files)
8 Spline vertex created by spline-fitting
16 Spline frame control point
32 3D polyline vertex
64 3D polygon mesh vertex
128 Polyface mesh vertex

Every Vertex that is part of a polyface mesh has the 128 bit set in its Vertex flags (70)
group. If the entity specifies the coordinates of a vertex of the mesh, the 64 bit is set
as well and the 10, 20, and 30 groups give the vertex coordinates. The vertex indexes
are determined by the order in which the Vertex entities appear within the Polyline,
with the first numbered 1.

If the Vertex defines a face of the mesh, its Vertex flags (70) group has the 128 bit set
but not the 64 bit. The 10, 20, and 30 (location) groups of the face entity are
irrelevant and are always written as zero in a DXF file. The vertex indexes that define
the mesh are given by 71, 72, 73, and 74 groups, the values of which are integers
specifying one of the previously defined vertices by index. If the index is negative, the
edge that begins with that vertex is invisible. The first zero vertex marks the end of
the vertices of the face. Since the 71 through 74 groups are optional fields with
default values of zero, they are present in DXF only if nonzero.
SEQEND No fields. This entity marks the end of vertices (Vertex type name) for a Polyline, or
the end of Attribute entities (Attrib type name) for an Insert entity that has Attributes
(indicated by 66 group present and nonzero in Insert entity).
3DFACE Four points defining the corners of the face: (10, 20, 30), (11, 21, 31), (12, 22, 32), and
(13, 23, 33). 70 (invisible edge flags -optional 0). If only three points are entered
(forming a triangular face), the third and fourth points will be the same. The
meanings of the bit-coded “invisible edge flags” are shown in the following table:

25
Table 22. Group 70 bit codes for 3D Face entity

Flag bit Meaning


value

1 First edge is invisible


2 Second edge is invisible
4 Third edge is invisible
8 Fourth edge is invisible

VIEWPORT 10, 20, 30 (center point of entity in paper space coordinates), 40 (width in paper
space units), 41 (height in paper space units), 68 (viewport status field), 69 (viewport
ID, permanent during editing sessions, but mutable between sessions; the paper
space viewport entity always has an ID of 1).

The value of the viewport status field (68) is interpreted as follows:

-1 On, but is fully off-screen or is one of the viewports not active


because the $MAXACTVP count is currently being exceeded.

0 Off.

<positive value> On, active and the value indicates the order of “stacking” for the
viewports, with 1 applying to the active viewport, which is also
the highest, 2 applying to the next viewport in the stack, and so
on.

In addition, the extended entity data groups in the following table apply to viewports.

Note: In contrast to normal entity data, the same extended entity group code can
appear multiple times, and order is important.
Table 23. Extended entity group codes for Viewports

Group Description

1001 Application name. This field will always be the string “ACAD”
1000 Begin viewport data. This field will always be the string “MVIEW”.
Other data groups may appear in the future
1002 Begin viewport descriptor data. This field will always be the string
“{“
1070 Extended entity data version number. For Release 11 and 12, this
field will always be the integer 16
1010 View target point X value
1020 View target point Y value

26
Table 24. Extended entity group codes for Viewports (continued)

Group Description

1030 View target point Z value


1010 View direction vector X value
1020 View direction vector Y value
1030 View direction vector Z value
1040 View twist angle
1040 View height
1040 View center point X value
1040 View center point Y value
1040 Perspective lens length
1040 Front clip plane Z value
1040 Back clip plane Z value
1070 View mode
1070 Circle zoom
1070 Fast zoom setting
1070 UCSICON setting
1070 Snap ON/OFF
1070 Grid ON/OFF
1070 Snap style
1070 Snap ISOPAIR
1040 Snap angle
1040 Snap base point UCS X coordinate
1040 Snap base point UCS Y coordinate
1040 Snap X spacing
1040 Snap Y spacing
1040 Grid X spacing
1040 Grid Y spacing
1070 Hidden in plot flag
1002 Begin frozen layer list (possibly empty). This field will always be the
string “{“

27
Table 25. Extended entity group codes for Viewports (continued)

Group Description

1003… The names of layers frozen in this viewport. This list may include
Xref-dependent layers. Any number of 1003 groups may appear
here
1002 End frozen layer list. This field will always be the string “}”
1002 End viewport data. This field will always be the string “}”

DIMENSION 2 (name of pseudo-Block containing the current dimension entity geometry), 3


(dimension style name), 10, 20, 30 (definition point for all dimension types), 11, 21,
31 (middle point of dimension text ), 12, 22, 32 (dimension block translation vector),
70 (Dimension type), 1 (dimension text explicitly entered by the user. If null or “<>”,
the dimension measurement is drawn as the text, if “ “ [one blank space], the text is
suppressed. Anything else is drawn as the text). 13, 23, 33 (definition point for linear
and angular dimensions), 14, 24, 34 (definition point for linear and angular
dimensions), 15, 25, 35 (definition point for diameter, radius, and angular
dimensions), 16, 26, 36 (point defining dimension arc for angular dimensions), 40
(leader length for radius and diameter dimensions), 50 (angle of rotated, horizontal,
or vertical linear dimensions).

The dimension type (group code 70) is an integer-coded field with the following
values:
Table 26. Group 70 integer codes for Dimension entity

Value Meaning

0 Rotated, horizontal, or vertical


1 Aligned
2 Angular
3 Diameter
4 Radius
5 Angular 3-point
6 Ordinate
64 Ordinate type. This is a bit value (bit 7) used only with integer value
6. If set, ordinate is X-type; if not set, ordinate is Y-type
128 This is a bit value (bit 8) added to the other group 70 values if the
dimension text has been positioned at a user-defined location
rather than at the default location

28
In addition, all dimension types have an optional group code (51) that indicates the
horizontal direction for the Dimension entity. This determines the orientation of
dimension text and dimension lines for horizontal, vertical, and rotated linear
dimensions. This group value is the negative of the Entity Coordinates Systems (ECS)
angle of the UCS X axis in effect when the Dimension was drawn. The X axis of the
UCS in effect when the Dimension was drawn is always parallel to the XY plane for the
Dimension’s ECS, and the angle between the UCS X axis and the ECS X axis is a single
2D angle. The value in group 51 is the angle from horizontal (the effective X axis) to
the ECS X axis. Entity Coordinate Systems (ECS) are described later in this section.

Linear dimension types with an oblique angle have an optional group code (52).
When added to the rotation angle of the linear dimension (group code 50) this gives
the angle of the extension lines. The optional group code 53 is the rotation angle of
the dimension text away from its default orientation (the direction of the dimension
line).

For all dimension types, the following groups represent 3D WCS points:

10, 20, 20
13, 23, 33
14, 24, 34
15, 25, 35
For all dimension types, the following groups represent 3D ECS points:

11, 21, 31
12, 22, 32
16, 26, 36
Linear (13, 23, 33) The point used to specify the first extension line.
(14, 24, 34) The point used to specify the second extension line.
(10, 20, 30) The point used to specify the dimension line.

29
Angular (13, 23, 33) and (14, 24, 34) The endpoints of the first extension line.
(10, 20, 30) and (15, 25, 35) The endpoints of the second extension line.
(16, 26, 36) The point used to specify the dimension line arc.

Angular (15, 25, 35) The vertex of the angle.


(3-point) (13, 23, 33) The endpoints of the first extension line.
(14, 24, 34) The endpoints of the second extension line.
(10, 20, 30) The point used to specify the dimension line arc.

Diameter (15, 25, 35) The point used to pick the circle/arc to dimension.
(10, 20, 30) The point on that circle directly across from the pick point.

30
Radius (15, 25, 35) The point used to pick the circle/arc to dimension.
(10, 20, 30) The center of that circle.

Ordinate (13, 23, 33) The point used to select the feature.
(14, 24, 34) The point used to locate the leader end point.

Entity Coordinate Systems (ECS)


To save space in the drawing database (and in the DXF file), the points associated with
each entity are expressed in terms of the entity’s own Entity Coordinate System (ECS).
With ECS, the only additional information needed to describe the entity’s position in 3D
space is the 3D vector describing the Z axis of the ECS, and the elevation value.

For a given Z axis (or extrusion) direction, there are an infinite number of coordinate
systems, defined by translating the origin in 3D space and by rotating the X and Y axes
around the Z axis. However, for the same Z axis direction, there is only one Entity
Coordinate System. It has the following properties:

• Its origin coincides with the WCS origin.

• The orientation of the X and Y axes within the XY plane are calculated in an
arbitrary, but consistent manner. AutoCAD performs this calculation using the
arbitrary axis algorithm (described later in this section).

For some entities, the ECS is equivalent to the World Coordinate System and all points
(DXF groups 10 – 37) are expressed in World coordinates. See the following table.

31
Table 27. Coordinate systems associated with an entity type

Entities Notes

Line, Point, 3D Face, 3D These entities do not lie in a particular plane. All points are expressed in
Polyline, 3D Vertex, 3D World coordinates. Of these entities, only Lines and Points can be
Mesh, 3D Mesh vertex extruded; their extrusion direction can differ from the World Z axis
Circle, Arc, Solid, Trace, These entities are planar in nature. All points are expressed in Entity
Text, Attrib, Attdef, coordinates. All of these entities can be extruded; their extrusion direction
Shape, Insert, 2D can differ from the World Z axis
Polyline, 2D Vertex
Dimensions Some of a Dimension’s points are expressed in WCS, and some in ECS
Viewport Expressed in World coordinates
Others The remaining entities have no point data and their coordinate systems
are therefore irrelevant

Once AutoCAD has established the ECS for a given entity, here’s how it works:

• The elevation value stored with an entity indicates how far along the Z axis to shift
the XY plane from the WCS origin to make it coincide with the plane that the entity
is in. How much of this is the user-defined elevation is unimportant.

• Any 2D points entered through the UCS are transformed into the corresponding 2D
points in the ECS, which is shifted and rotated with respect to the UCS.

These are a few ramifications of this process:

• You cannot reliably find out what UCS was in effect when an entity was acquired.

• When you enter the XY coordinates of an entity in a given UCS and then do a
DXFOUT, you probably won’t recognize those XY coordinates in the DXF file. You
must know the method by which AutoCAD calculates the X and Y axes in order to
work with these values.

• The elevation value stored with an entity and output in DXF files is a sum of the Z-
coordinate difference between the UCS XY plane and the ECS XY plane, and the
elevation value that the user specified at the time the entity was drawn.

32
Arbitrary Axis Algorithm
The arbitrary axis algorithm is used by AutoCAD internally to implement the arbitrary
but consistent generation of Entity Coordinate Systems for all entities except Lines,
Points, 3D Faces, and 3D Polylines, which contain points in World coordinates.

Given a unit-length vector to be used as the Z axis of a coordinate system, the arbitrary
axis algorithm generates a corresponding X axis for the coordinate system. The Y axis
follows by application of the right-hand rule.

The method is to examine the given Z axis (also called the normal vector) and see if it is
close to the positive or negative World Z axis. If it is, cross the World Y axis with the
given Z axis to arrive at the arbitrary X axis. If not, cross the World Z axis with the given Z
axis to arrive at the arbitrary X axis. The boundary at which the decision is made was
chosen to be both inexpensive to calculate and completely portable across machines.
This is achieved by having a sort of “square” polar cap, the bounds of which is 1/64,
which is precisely specifiable in 6 decimal fraction digits and in 6 binary fraction bits.

The algorithm does the following (all vectors are assumed to be in 3D space, specified in
the World Coordinate System):
Let the given normal vector be called N.
Let the World Y axis be called Wy, which is always (0,1,0).
Let the World Z axis be called Wz, which is always (0,0,1).

Here we are looking for the arbitrary X and Y axes to go with the normal N. They’ll be
called Ax and Ay. N could also be called Az (the arbitrary Z axis):
If (abs (Nx) < 1/64) and (abs (Ny) < 1/64) then
Ax = Wy x N (where "x" is the cross-product operator).
Otherwise,
Ax = Wz x N.
Scale Ax to unit length.

The method of getting the Ay vector is:


Ay = N x Ax.
Scale Ay to unit length

Extended Entity Data


Extended entity data is created by applications such as the Advanced Modeling
Extension (AME), or by routines written with AutoLISP or ADS. Extended entity data is
also produced by creating PostScript output with PSOUT. If an entity contains extended
data, it follows the entity’s normal definition data.

33
The group codes 1000 through 1071 describe extended entity data. The following is an
example of an entity containing extended entity data in DXF format.
0
INSERT
8
X
5
5
F11
15
2 — Normal entity definition data.
BLOCK_A
10
0.0
20
0.0
30
0.0
1001
AME_SOL
1002
{
1070
0
1071

1.95059E+06
1070
519
1010
2.54717
1020
2.122642 — Extended entity data.
1030
2.049201
1005
ECD
1005
EE9
1005
0
1040
0.0
1040
1.0
1000
MILD_STEEL

34
Organization of Extended Entity Data
The group code 1001 indicates the beginning of extended entity data. In contrast to
normal entity data, the same group code can appear multiple times, and order is
important.

Extended entity data is grouped by registered application name. Each registered


application’s group begins with a 1001 group code with the application name as the
string value. Registered application names correspond to APPID symbol table entries.

An application can use as many APPID names as needed. APPID names are permanent,
although they can be purged if they aren’t currently used in the drawing.

Each APPID name can have no more than one data group attached to each entity.
Within an application’s group, the sequence of extended entity data groups and their
meaning is defined by the application.

Note: PostScript images and PostScript fill requests for Polylines are stored in the
AutoCAD database as extended entity data belonging to the
AUTOCAD_POSTSCRIPT_FIGURE application.

The following extended entity data group codes are supported by AutoCAD, which
maintains and manipulates their values as described:
Table 28. Extended entity data group codes and descriptions

Entity Name Group Description


Code

String 1000 Strings in extended entity data can be up to 255 bytes long
(with the 256th byte reserved for the null character)
Application 1001 Application names can be up to 31 bytes long (the 32d byte is
name also a reserved for the null character). Use of application names is
string described in more detail later in this section
value Caution: Do not add a 1001 group into your extended entity
data, as AutoCAD will assume it is the beginning of a new
application extended entity data group
Control 1002 An extended data control string can be either “{“ or “}”: these
string braces enable applications to organize their data by subdividing
the data into lists. The left brace begins a list, and a right brace
terminates the most recent list; lists can be nested
When AutoCAD reads the extended entity data for a particular
application, it checks to ensure that braces are balanced
correctly
Layer name 1003 Name of the layer associated with the extended entity data

35
Table 29. Extended entity data group codes and descriptions (continued)

Entity Name Group Description


Code

Binary data 1004 Binary data is organized into variable-length chunks. The
maximum length of each chunk is 127 bytes. Binary data is
represented as a string of hexadecimal digits, two per binary
byte, in ASCII DXF files
Database 1005 Handles of entities in the drawing database
handle Note: When a drawing with handles and extended entity data
handles is imported into another drawing using INSERT, INSERT
*, XREF Bind, XBIND, or partial DXFIN, the extended entity data
handles are translated in the same manner as their
corresponding entity handles, thus maintaining their binding.
This is also done in the EXPLODE Block operation, or for any
other AutoCAD operation. When AUDIT detects an extended
entity data handle that doesn’t match the handle of an entity in
the drawing file, it is considered an error. If AUDIT is fixing
entities, it sets the handle to 0.
3 reals 1010, Three real values, in the order X, Y, Z. They can be used as a
1020, point or vector record. AutoCAD never alters their value
1030
World space 1011, Unlike a simple 3D point, the World space coordinates are
position 1021, moved, scaled, rotated, and mirrored along with the parent
1031 entity to which the extended data belongs. The world space
position is also stretched when the STRETCH command is
applied to the parent entity and this point lies within the select
window
World space 1012, Also a 3D point that is scaled, rotated, and mirrored along with
displacement 1022, the parent (but not moved or stretched)
1032
World 1013, Also a 3D point that is rotated and mirrored along with the
direction 1023, parent (but not moved, scaled, or stretched)
1033
Real 1040 A real value
Distance 1041 A real value that is scaled along with the parent entity
Scale factor 1042 Also a real value that is scaled along with the parent. The
difference between a distance and a scale factor is application-
defined
Integer 1070 A 16-bit integer (signed or unsigned)
Long 1071 A 32-bit signed (long) integer

36
For more information on extended entity data and the APPID table, refer to the ADS
Programmer’s Reference and the AutoLISP Reference.

Writing DXF Interface Programs


Writing a program that communicates with AutoCAD via the DXF mechanism appears
more difficult than it is. The DXF format makes it easy to ignore information you don’t
need while reading the information you do need.

The following example is a Microsoft BASIC™ program that reads a DXF file and extracts
all the Line entities from the drawing (ignoring lines that appear inside Blocks). It prints
the endpoints of these lines on the screen. This program is presented as an example of
just how simple a DXF-reading program can be.

1000 REM
1010 REM Extract lines from DXF file
1020 REM
1030 G1% = 0
1040 LINE INPUT "DXF file name: "; A$
1050 OPEN "i", 1, A$ + ".dxf"
1060 REM
1070 REM Ignore until section start encountered
1080 REM
1090 GOSUB 2000
1100 IF G% <> 0 THEN 1090
1110 IF S$ <> "SECTION" THEN 1090
1120 GOSUB 2000
1130 REM
1140 REM Skip unless ENTITIES section
1150 REM
1160 IF S$ <> "ENTITIES" THEN 1090
1170 REM
1180 REM Scan until end of section, processing LINEs
1190 REM
1200 GOSUB 2000
1210 IF G% = 0 AND S$ = "ENDSEC" THEN 2200
1220 IF G% = 0 AND S$ = "LINE" THEN GOSUB 1400 : GOTO 1210
1230 GOTO 1200
1400 REM
1410 REM Accumulate LINE entity groups
1420 REM
1430 GOSUB 2000
1440 IF G% = 10 THEN X1 = X : Y1 = Y : Z1 = Z
1450 IF G% = 11 THEN X2 = X : Y2 = Y : Z2 = Z
1460 IF G% = 0 THEN PRINT "Line from (";X1;",";Y1;",";Z1;")
to (";X2;",";Y2;",";Z2;")" : RETURN
1470 GOTO 1430

37
2000 REM
2010 REM Read group code and following value
2020 REM For X coordinate, read Y and possibly Z also
2030 REM
2040 IF G1% < 0 THEN G% = -G1% : G1% = 0 ELSE INPUT #1, G%
2050 IF G% < 10 OR G% = 999 THEN LINE INPUT #1, S$ : RETURN
2060 IF G% >= 38 AND G% <= 49 THEN INPUT #1, V : RETURN
2080 IF G% >= 50 AND G% <= 59 THEN INPUT #1, A : RETURN
2090 IF G% >= 60 AND G% <= 69 THEN INPUT #1, P% : RETURN
2100 IF G% >= 70 AND G% <= 79 THEN INPUT #1, F% : RETURN
2110 IF G% >= 210 AND G% <= 219 THEN 2130
2115 IF G% >= 1000 THEN LINE INPUT #1, T$ : RETURN
2120 IF G% >= 20 THEN PRINT "Invalid group code";G% : STOP
2130 INPUT #1, X
2140 INPUT #1, G1%
2150 IF G1% <> (G%+10) THEN PRINT "Invalid Y coord
code";G1% : STOP
2160 INPUT #1, Y
2170 INPUT #1, G1%
2180 IF G1% <> (G%+20) THEN G1% = -G1% ELSE INPUT #1, Z
2190 RETURN
2200 CLOSE 1

Writing a program that constructs a DXF file is more difficult. You must maintain
consistency within the drawing, although AutoCAD lets you omit many items in a DXF
file and still obtain a usable drawing. The entire HEADER section can be omitted if you
don’t set header variables. Any of the tables in the TABLES section can be omitted if you
don’t need to make entries, and the entire TABLES section can be dropped if nothing in
it is required. If you define any linetypes in the LTYPE table, this table must appear
before the LAYER table. If no Block Definitions are used in the drawing, the BLOCKS
section can be omitted. If present, the BLOCKS section must appear before the ENTITIES
section. Within the ENTITIES section, you can reference layer names even though you
haven’t defined them in the LAYER table. Such layers are automatically created with
color 7 and the CONTINUOUS linetype. The EOF item must be present at the end-of-file.

The following Microsoft BASIC program constructs a DXF file representing a polygon
with a specified number of sides, leftmost origin point, and side length. This program
supplies only the ENTITIES section of the DXF file, and places all entities generated on
the default layer 0. Since this program doesn’t create the drawing header, the drawing
limits, extents, and current view will be invalid after performing a DXFIN on the drawing
generated by this program. You can do a ZOOM E to fill the screen with the drawing
generated. Then adjust the lines manually.

1000 REM
1010 REM Polygon generator
1020 REM
1030 LINE INPUT "Drawing (DXF) file name: "; A$

38
1040 OPEN "o", 1, A$ + ".dxf"
1050 PRINT #1, 0
1060 PRINT #1, "SECTION"
1070 PRINT #1, 2
1080 PRINT #1, "ENTITIES"
1090 PI = ATN(1) * 4
1100 INPUT "Number of sides for polygon: "; S%
1110 INPUT "Starting point (X,Y): "; X, Y
1120 INPUT "Polygon sides: "; D
1130 A1 = (2 * PI) / S%
1140 A = PI / 2
1150 FOR I% = 1 TO S%
1160 PRINT #1, 0
1170 PRINT #1, "LINE"
1180 PRINT #1, 8
1190 PRINT #1, "0"
1200 PRINT #1, 10
1210 PRINT #1, X
1220 PRINT #1, 20
1230 PRINT #1, Y
1240 PRINT #1, 30
1250 PRINT #1, 0.0
1260 NX = D * COS(A) + X
1270 NY = D * SIN(A) + Y
1280 PRINT #1, 11
1290 PRINT #1, NX
1300 PRINT #1, 21
1310 PRINT #1, NY
1320 PRINT #1, 31
1330 PRINT #1, 0.0
1340 X = NX
1350 Y = NY
1360 A = A + A1
1370 NEXT I%
1380 PRINT #1, 0
1390 PRINT #1, "ENDSEQ"
1400 PRINT #1, 0
1410 PRINT #1, "EOF"
1420 CLOSE 1

As long as a properly formatted item appears on the line on which the data is expected,
DXFIN accepts it (of course, string items should not have leading spaces unless these are
intended to be part of the string). This program takes advantage of this flexibility in
input format, and does not generate a file exactly like one generated by AutoCAD.

39
In the case of error loading a DXF file using DXFIN, AutoCAD reports the error with a
message indicating the nature of the error and the last line processed in the DXF file
before the error was detected. This may not be the line on which the error occurred,
especially in the case of errors such as omissions of required groups.

Binary DXF Files


The ASCII DXF file format is a complete representation of an AutoCAD drawing in an
ASCII text form easily processed by other programs. In addition, AutoCAD can produce
or read a binary form of the full DXF file and accept limited input in another binary file
format. These binary files are described in the following sections.

The DXFOUT command provides a Binary option that writes binary DXF files. Such a file
contains all of the information present in an ASCII DXF file, but in a more compact form
that takes, typically, 25% less file space and can be read and written more quickly
(typically 5 times faster) by AutoCAD. Unlike ASCII DXF files, which entail a trade-off
between size and floating-point accuracy, binary DXF files preserve all of the accuracy in
the drawing database. AutoCAD Release 10 was the first version to support this form of
DXF file; it cannot be read by older versions.

A binary DXF file begins with a 22-byte sentinel consisting of:

AutoCAD Binary DXF<CR><LF><SUB><NUL>

Following the sentinel are (group, value) pairs as in an ACSII DXF file, but represented in
binary form. The group code is a single-byte binary value, and the value that follows is
one of the following:

• A two-byte integer with the least-significant byte first and the most-significant
byte last.
• An eight-byte IEEE double precision floating-point number stored with the least-
significant byte first and the most-significant byte last.
• An ASCII string terminated by a zero (NUL) byte.

The type of the datum following a group is determined from the group code by the
same rules used in decoding ASCII DXF files. Translation of angles to degrees, and dates
to fractional Julian date representation, is performed for binary files as well as for ASCII
DXF files. The comment group, 999, is not used in binary DXF files.

Extended entity data group codes are represented in Binary DXF as a single byte with
the value 255, followed by 2-byte integer value containing the actual group code,
followed by the actual value.

40
Extended entity data long (group code 1071) values occupy 4 bytes of data. Extended
entity data binary chunks (group code 1004) are represented as a single-byte, unsigned
integer length, followed by the specified number of bytes of chunk data. For example, to
transfer an extended entity data long group, the following values would appear,
occupying 1, 2, and 4 bytes respectively:

255 Escape group code.


1071 True group code.
999999 Value for the 1071 group code.

DXFOUT writes binary DXF files with the same file type (.dxf) as for ASCII DXF files. The
DXFIN command automatically recognizes a binary file by means of its sentinel string.
There is no need for you to identify it as a binary file.

If DXFIN encounters an error in a binary DXF file, it reports the byte address within the
file where the error was detected.

Binary Drawing Interchange (DXB) Files


The DXF file formats are complete representations of an AutoCAD drawing that can be
written and read by AutoCAD and other programs. However, programs executed via the
external commands facility often need to supply simple geometric input to AutoCAD.
For these purposes, AutoCAD supports another file format, called DXB (for drawing
interchange binary), which is limited in the entities it can represent.

DXBIN Command
To load a DXB file, enter the DXBIN command:

Command: dxbin

When AutoCAD prompts you, respond with the name of the file you want to load. You
don’t need to include a file type; .dxb is assumed.

DXB File format


Important: This information is for experienced programmers and is subject to change
without notice.

The format of a DXB file is as follows:

Header: "AutoCAD DXB 1.0" CR LF ^Z NUL (19 bytes)


Data: …Zero or more data records…
Terminator: NUL (1 byte)

41
Each data record begins with a single byte identifying the record type, followed by data
items. The data items have various forms of representation and encoding. In the
descriptions following, each data item is prefixed with a letter and a hyphen. The
meaning of the letter codes is as follows:

w- 16-bit integer, byte reversed in the standard 80x86 style (least-


significant byte first, most-significant byte second)
f- IEEE 64-bit floating-point value stored with lsb first, msb last (as
stored by an 80x87).
l- 32-bit integer with the bytes reversed 80x86 style.
n- Either a 16-bit integer or a floating-point number, depending on
the most recent setting of the number mode data item. The
number mode defaults to 0, signifying integers. If set to 1, all n-
items will be read as floating points.
u- Either a 32-bit integer or a floating-point number, depending on
the most recent number mode setting. If a 32-bit integer, the
value is scaled by multiplying it by 65,536 (216). If a floating-point
value, no scaling is applied.
a- An angle. If number mode is integer, this is a 32-bit integer
representing an angle in units of millionths of a degree (range 0
to 360,000,000). If a floating-point number, it represents
degrees.

In the following table, the lengths include the item-type byte and assume the number
mode is set to zero (integer mode). If number mode is floating-point, add 6 bytes to the
length for each n- item present and 4 bytes for each a- or u- item present.
Table 30. Byte length for item types

Item Type Code Data Items Length


(decimal) (bytes)

Line 1 n-fromx n-fromy 13


n-tox n-toy
n-fromx n-fromy n-fromz
n-tox n-toy n-toz
Point 2 n-x n-y 5
Circle 3 n-ctrx n-ctry n-rad 7
Arc 8 n-ctrx n-ctry n-rad 19
a-starta a-enda
Trace 9 n-x1 n-y1 n-x2 n-y2 17
n-x3 n-y3 n-x4 n-y4

42
Table 31. Byte length for item types (continued)

Item Type Code Data Items Length


(decimal) (bytes)

Solid 11 n-x1 n-y1 n-x2 n-y2 17


n-x3 n-y3 n-x4 n-y4
Seqend 17 (none) 1
Polyline 19 w-closureflag 3
Vertex 20 n-x n-y 5
3Dface 22 n-x1 n-y1 n-z1 25
n-x2 n-y2 n-z2
n-x3 n-y3 n-z3
n-x4 n-y4 n-z4
Scale Factor 128 f-scalefac 9
New Layer 129 "layername" NUL layername
length + 2
Line Extension 130 n-tox n-toy 5
Trace Extension 131 n-x3 n-y3 n-x4 n-y4 9
Block Base 132 n-bx n-by 5
Bulge 133 u-2h/d 5
Width 134 n-startw n-endw 5
Number Mode 135 w-mode 3
New Color 136 w-colornum 3
3Dline Extension 137 n-tox n-toy n-toz 7

The Line Extension item extends the last line or line extension from its To point to a new
To point. The Trace Extension item extends the last trace solid, or Trace Extension from
its x3,y3-x4,y4 ending line to a new x3,y3--x4,y4 line.

The Scale Factor is a floating-point value by which all integer coordinates are multiplied
to obtain the floating-point coordinates used by the entities. The initial scale factor
when a file is read is 1.0. The New Layer item creates a layer if none exists, giving the
new layer the same defaults as the LAYER New command, and sets that layer as the
current layer for subsequent entities. At the end of the DXB file load, the layer in effect
before the command is restored.

The Block Base item specifies the base (origin) point of a created Block. The Block base
must be defined before the first entity record is encountered. If DXB does not define a
Block, this specification is ignored.

43
A Polyline consists of straight segments of fixed width connecting the vertices, except as
overridden by the Bulge and Width items. The closure flag should be 0 or 1; if it is 1,
there is an implicit segment from the last vertex (immediately before the Seqend) to the
first vertex.

A Bulge item, encountered between two Vertex items (or after the last Vertex of a
closed Polyline), indicates that the two vertices are connected by an arc rather than a
straight segment. If the distance between the vertices has length d, and the
perpendicular distance from the midpoint of that segment to the arc is h, then the
magnitude of the Bulge is (2 * h / d). The sign is negative if the arc from the first vertex
to the second is clockwise. A semi-circle thus has a bulge of 1 (or -1). If the number
mode is 0 (integer), Bulge items are scaled by 216. If the number mode has been set to
floating-point, then the floating-point value supplied is 2*h/d (not scaled).

The Width item indicates the starting and ending widths of the segment (straight or
curved) connecting two vertices. This width stays in effect until the next Width item or
the Seqend. If there is a Width item between the Polyline item and the first Vertex, it is
stored as default width for the Polyline; this saves considerable database space if the
Polyline has several segments of this width.

The Number Mode item controls the mode of items with types given in the table above
as n-, a-, or u-. If the value supplied is zero, these values will be integers, otherwise
floating-point.

To remember the last to-point, lines share the same cells, so don’t mix extension groups
for the two entities without an initial group before the extension. There is no extension
group for 3Dfaces, as there’s no obvious edge to extend from.

The New Color group specifies the color for subsequent entities in the DXB file. The w-
colornum word argument is in the range from 0 to 256. 0 means color by block, 1–255
are the standard AutoCAD colors, and 256 means color by layer. A color outside the
range from 0 to 256 sets the color back to the current entity color (you can do this
deliberately, and it can be quite handy). The initial entity color of material added by
DXBIN is the current entity color.

All points specified in the DXB file are interpreted in terms of the current UCS at the
time the DXBIN command is executed.

Writing DXB Files


There is no direct AutoCAD command to write a DXB file, but the ADI "AutoCAD file
output formats" plotter driver can write such a file. If you want to create a DXB file from
an AutoCAD drawing, configure the "file output formats" plotter and select its "AutoCAD
DXB file" output option.

44
Appendix: DXF Group Code Summary
This appendix is a reference to the DXF group codes. The first section lists the group
codes in numerical order. The second organizes them by entity.

Important: The group codes encountered by an AutoLISP or ADS application differ


slightly from the group codes in a DXF file. This appendix describes the codes from an
application’s point of view.

Group Codes in Numerical Order


This table shows negative group codes, which don’t appear in a DXF file but do appear
to programs. It also omits some codes that don’t appear to programs. In the table,
“(fixed)” indicates that this group code always has the same purpose. The purpose of
group codes that aren’t fixed can vary depending on context.
Table A–1. Entity group codes by number

Group code Value type

–4 Conditional operator (used only with (ssget) and ads_ssget())


–3 Extended entity data (XDATA) sentinel (fixed)
–2 Entity name reference (fixed)
–1 Entity name (changes each time drawing is opened; never saved); (fixed)
0 Starts an entity. The type of entity is given by the text value that follows
this group (fixed)
1 The primary text value for an entity
2 A name: Attribute tag, Block name, and so on
3–4 Other textual or name values

5 Entity handle expressed as a hexadecimal string (fixed)


6 Linetype name (fixed)
7 Text style name (fixed)
8 Layer name (fixed)
10 Primary point (start point of a Line or Text entity, center of a Circle, etc.)
11–18 Other points
Note: These are the only coordinate group codes that an application sees.
The Y (20–28) and Z (30–38) coordinates that appear in a DXF file are
passed to an application as part of an AutoLISP point list or an ADS result
buffer
39 This entity’s thickness is nonzero (fixed)

45
Table A–1. Entity group codes by number (continued)

Group code Value type

40–48 Floating-point values (text height, scale factors, etc.)


49 Repeated value—multiple 49 groups may appear in one entity for variable-
length tables (such as the dash lengths in the LTYPE table). A 7x group
always appears before the first 49 group to specify the table length
50–58 Angles
62 Color number (fixed)
66 “Entities follow” flag (fixed)
67 Space (this is, model or paper space) (fixed)
70–78 Integer values such as repeat counts, flag bits, or modes
210 Extrusion direction (fixed)
Note: As with point coordinates, an application sees only the 210 group.
The Y (220) and Z (230) components of an extrusion vector are passed to
an application as part of an AutoLISP point list or an ADS result buffer
999 Comments
1000 An ASCII string (up to 255 bytes long) in XDATA
1001 Registered application name (ASCII string up to 31 bytes long) for XDATA
(fixed)
1002 XDATA control string (“{“ or “}”); (fixed)
1003 Layer name in XDATA
1004 Chunk of bytes (up to 127 bytes long) in XDATA
1005 Entity handle in XDATA
1010 A point in XDATA
1011 A 3D World space position in XDATA
1012 A 3D World space displacement in XDATA
1013 A 3D World space direction in XDATA
Note: Again, these are the only coordinate group codes that an application
sees. The Y (1020, 1021, 1022, or 1023) and Z (1030, 1031, 1032, or 1033)
coordinates that appear in a DXF file are passed to an application as part of
an AutoLISP point list or an ADS result buffer
1040 Floating-point value in XDATA
1041 Distance value in XDATA
1042 Scale factor in XDATA

46
Table A–1. Entity group codes by number (continued)

Group code Value type

1070 16-bit integer in XDATA


1071 32-bit signed long integer in XDATA

Group Codes by Entity


Table A-2 shows group codes that apply to virtually all entities (strictly speaking, handles
don’t appear in tables and group 210 applies only to planar entities; optional codes are
shown in gray). When you refer to Table A-3 and Table A-5, which list the codes
associated with an entity, don’t forget that the codes shown here can also be present.
Table A–2. Group codes that apply to all entities

Group Meaning If omitted


code defaults to . . .

–1 Entity name (changes each time drawing is opened) Not omitted


0 Entity type Not omitted
8 Layer name Not omitted
5 Handle (always present for Block definitions) none
6 Linetype name (present if not BYLAYER). The special name BYBLOCK BYLAYER
indicates a floating linetype
39 Thickness (present if nonzero) 0
62 Color number (present if not BYLAYER). Zero indicates the BYBLOCK BYLAYER
(floating) color. 256 indicates BYLAYER
67 Absent or zero indicates entity is in model space. One indicates 0
entity is in paper space
Other entity-definition groups appear here
210 Extrusion direction (present if the entity’s extrusion direction is not (0,0,1)
parallel to the World Z axis)
This group applies to Line, Point, Circle, Shape, Text, Arc, Trace,
Solid, Block Reference (Insert), Polyline, Dimension, Attribute, and
Attribute Definition entities

Caution: Although these tables show the order of group codes as they usually appear,
don’t write programs that rely on this order, which can change under certain conditions
or in a future AutoCAD release. Code to handle an entity should be driven by a case
(switch) or a table, so it can process each group correctly even if the order is
unexpected.

47
Entity Group Codes
Table A-3 shows group codes for entities (as they would be saved in the ENTITIES
section of a DXF file; optional codes are shown in gray). For the codes that apply to
Block definitions and table entries, see “Block and Table Group Codes.”
Table A–3. Entity group codes by entity

Entity type Group codes Meaning

3DFACE 10 First corner


11 Second corner
12 Third corner
13 Fourth corner (if only three corners entered, this equals the
third corner)
70 Invisible edge flags (optional; default: 0):
1 First edge is invisible
2 Second edge is invisible
4 Third edge is invisible
8 Fourth edge is invisible

ATTDEF 10 Text start point


40 Text height
1 Default value (string)
3 Prompt string
2 Tag string
70 Attribute flags:
1 Attribute is invisible (does not display)
2 This is a constant Attribute
4 Verification is required on input of this Attribute
8 Attribute is preset (no prompt during insertion)
73 Field length (optional; default: 0)
50 Text rotation (optional; default: 0)
41 Relative X scale factor (optional; default: 1)
51 Oblique angle (optional; default: 0)
7 Text style name (optional; default: STANDARD)
71 Text-generation flags (optional; default: 0)—see TEXT
72 Horizontal text justification type (optional; default: 0)—see TEXT
74 Vertical text justification type (optional; default: 0)—see TEXT

48
Table A–3. Entity group codes by entity (continued)

Entity type Group codes Meaning

ATTDEF 11 Alignment point (optional; present only if 72 or 74 group is


(continued) present and nonzero)

ATTRIB 10 Text start point


40 Text height
1 Value (string)
2 Attribute tag (string)
70 Attribute flags:
1 Attribute is invisible (does not display)
2 This is a constant Attribute
4 Verification is required on input of this Attribute
8 Attribute is preset (no prompt during insertion)
73 Fixed length (optional; default: 0)
50 Text rotation (optional; default: 0)
41 Relative X scale factor (optional; default :1)
51 Oblique angle (optional; default: 0)
7 Text style name (optional; default: STANDARD)
71 Text-generation flags (optional; default: 0)—see TEXT
72 Horizontal text justification type (optional; default: 0)—see TEXT
74 Vertical text justification type (optional; default: 0)—see TEXT
11 Alignment point (optional; present only if 72 or 74 group is
present and nonzero)

ARC 10 Center
40 Radius
50 Start angle
51 End angle

CIRCLE 10 Center point


40 Radius

DIMENSION 2 Name of pseudo-Block that contains the dimension picture


3 Dimension style name
10 Definition point
11 Middle point of dimension text

49
Table A–3. Entity group codes by entity (continued)

Entity type Group codes Meaning

DIMENSION 12 Insertion point for clones of a dimension (for Baseline and


(continued) Continue)
70 Dimension type—these are integer codes, not bit-coded:
0 Rotated, horizontal, or vertical
1 Aligned
2 Angular
3 Diameter
4 Radius
5 Angular 3 point
6 Ordinate
64 X-type ordinate at the default location
192 X-type ordinate at a user-defined location
1 Dimension text entered by the user (optional; default: the
measurement)
13 Definition point for linear and angular dimensions
14 Definition point for linear and angular dimensions
15 Definition point for diameter, radius, and angular dimensions
16 Point defining dimension arc for angular dimensions
40 Leader length for radius and diameter dimensions
50 Angle of rotated, horizontal, or vertical linear dimensions
51 Horizontal direction (optional)
52 Extension line angle for oblique linear dimensions (optional)
53 Rotation angle of dimension text (optional)

INSERT 66 Variable attributes-follow flag (optional; default: 0)


2 Block name
10 Insertion point
41 X scale factor (optional; default: 1)
42 Y scale factor (optional; default: 1)
43 Z scale factor (optional; default: 1)
50 Rotation angle (optional; default: 0)
70 Column count (optional; default: 1)
71 Row count (optional; default: 1)
44 Column spacing (optional; default: 0)

50
Table A–3. Entity group codes by entity (continued)

Entity type Group codes Meaning

INSERT 45 Row spacing (optional; default: 0)


(continued)

LINE 10 Start point


11 End point

POINT 10 Point
50 Angle of X axis for the UCS in effect when the Point was drawn
(optional; default: 0). Used when PDMODE is nonzero

POLYLINE 66 Vertices-follow flag (always 1 for a Polyline)


10 A “dummy” point; the X and Y coordinates are always 0, and the
Z coordinate specifies the Polyline’s elevation
70 Polyline flag (optional; default: 0):
1 This is a closed Polyline (or a polygon mesh closed
in the M direction)
2 Curve-fit vertices have been added
4 Spline-fit vertices have been added
8 This is a 3D Polyline
16 This is a 3D Polygon mesh
32 The polygon mesh is closed in the N direction
64 This Polyline is a polyface mesh
128 This linetype pattern is generated continuously
around the vertices of this Polyline
40 Default starting width (optional; default: 0)
41 Default ending width (optional; default: 0)
71 Polygon mesh M vertex count (optional; default: 0)
72 Polygon mesh N vertex count (optional; default: 0)
73 Smooth surface M density (optional; default: 0)
74 Smooth surface N density (optional; default: 0)
75 Curves and smooth surface type (optional; default: 0)—these are
integer codes, not bit-coded:
0 No smooth surface fitted
5 Quadratic B-spline surface
6 Cubic B-spline surface
8 Bezier surface

SEQEND –2 Name of entity that began the sequence

51
Table A–3. Entity group codes by entity (continued)

Entity type Group codes Meaning

SHAPE 10 Insertion point


40 Size
2 Shape name
50 Rotation angle (optional; default: 0)
41 Relative X-scale factor (optional; default: 1)
51 Oblique angle (optional; default: 0)

SOLID 10 First corner


11 Second corner
12 Third corner
13 Fourth corner (if only three corners entered, this equals the
third corner)

TEXT 10 Insertion point


40 Height
1 Text value (the string itself)
50 Rotation angle (optional; default: 0)
41 Relative X-scale factor (optional; default: 1)
51 Oblique angle (optional; default: 0)
7 Text style name (optional; default: STANDARD)
71 Text generation flag (optional; default: 0):
2 Text is backward (mirrored in X)
4 Text is upside down (mirrored in Y)
72 Horizontal alignment (optional; default: 0)—these are integer
codes, not bit-coded:
0 Left
1 Center
2 Right
3 Aligned (if vertical alignment = 0)
4 Middle (if vertical alignment = 0)
5 Fit (if vertical alignment = 0)

52
Table A–3. Entity group codes by entity (continued)

Entity type Group codes Meaning

TEXT 73 Vertical alignment (optional; default: 0)—these are integer


(continued) codes, not bit-coded:
0 Baseline
1 Bottom
2 Middle
3 Top
11 Alignment point (optional; present only if 72 or 73 group is
present and nonzero)

TRACE 10 First corner


11 Second corner
12 Third corner
13 Fourth corner

VERTEX 10 Location
40 Starting width (optional; default: 0)
41 Ending width (optional; default: 0)
42 Bulge (optional; default: 0)
70 Vertex flags (optional; default: 0):
1 Extra vertex created by curve-fitting
2 Curve-fit tangent defined for this vertex. A curve-fit
tangent direction of 0 may be omitted from the
DXF output, but is significant if this bit is set
4 not used
8 Spline vertex created by spline-fitting
16 Spline frame control point
32 3D Polyline vertex
64 3D Polygon mesh vertex
128 Polyface mesh vertex
50 Curve-fit tangent direction (optional)

VIEWPORT 10 Center point


40 Width in paper space units
41 Height in paper space units
69 Viewport ID (changes each time the drawing is opened; never
saved)
68 Viewport status field

53
Table A–3. Entity group codes by entity (continued)

Entity type Group codes Meaning

VIEWPORT 1001 Application ID (“ACAD”). This begins a section of XDATA that


(continued) describes the Viewport. User application can’t modify this data,
see Table 16 for details.

Block and Table Group Codes


Table A-4 shows the 70 group flag bit values that apply to all table entries:
Table A–4. Group 70 bit codes that apply to all table entries

Flag bit value Value type

16 If set, table entry is externally dependent on an Xref


32 If this bit and bit 16 are both set, the externally dependent Xref has been
successfully resolved
64 If set, the table entry was referenced by at least one entity in the drawing
the last time the drawing was edited. (This flag is for the benefit of
AutoCAD commands; it can be ignored by most programs that read DXF
files, and need not be set by programs that write DXF files)

Table A-5 shows the group codes for Block definitions and table entries (as they would
be saved in the TABLES and BLOCKS section of a DXF file; optional codes are shown in
gray).
Table A–5. Block and table group codes by entity

Entity type Group codes Meaning

APPID 2 User-registered application name (for XDATA)


70 Standard flag values

BLOCK Note: A Block description also contains the standard entity groups shown in
Table A-2 except for the entity name (–1) group, which ads_tblnext()
and ads_tblsearch() do not return
2 Block name
70 Type flag:
1 This is an anonymous Block (generated by
hatching, associative dimensioning, other internal
operations, or an application)
2 Variable attributes follow
4 This Block is an external reference (Xref)
8 not used

54
Table A–5. Block and table group codes by entity

Entity type Group codes Meaning

BLOCK 16 This Block is externally dependent


(continued) 32 This is a resolved external reference, or dependent
of an external reference
64 This definition is referenced
10 Base point
1 Xref pathname (optional; only present if the Block is an Xref)

DIMSTYLE 2 Dimension style name


70 Standard flag values
3 DIMPOST
4 DIMAPOST
5 DIMBLK
6 DIMBLK1
7 DIMBLK2
40 DIMSCALE
41 DIMASZ
42 DIMEXO
43 DIMDLI
44 DIMEXE
45 DIMRND
46 DIMDLE
47 DIMTP
48 DIMTM
140 DIMTXT
141 DIMCEN
142 DIMTSZ
143 DIMALTF
144 DIMLFAC
145 DIMTVP
146 DIMTFAC
147 DIMGAP

55
Table A–5. Block and table group codes by entity (continued)

Entity type Group codes Meaning

DIMSTYLE 71 DIMTOL
(continued)
72 DIMLIM
73 DIMTIH
74 DIMTOH
75 DIMSE1
76 DIMSE2
77 DIMTAD
78 DIMZIN
170 DIMALT
171 DIMALTD
172 DIMTOFL
173 DIMSAH
174 DIMTIX
175 DIMSOXD
176 DIMCLRD
177 DIMCLRE
178 DIMCLRT

ENDBLK (No groups) End Block definition (appears only in BLOCKS table)

LAYER 2 Layer name


70 Layer flags:
1 If set, layer is frozen
2 If set, layer is frozen by default in new Viewports
4 If set, layer is locked
62 Color
6 Linetype

LTYPE 2 Linetype name


70 Standard flag values
3 Descriptive text for linetype
72 Alignment code
73 Number of dash length items

56
Table A–5. Block and table group codes by entity (continued)

Entity type Group codes Meaning

LTYPE 40 Total pattern length


(continued)
49 Dash length (optional; can be repeated)

STYLE 2 Style name


70 Standard flag values
40 Fixed text height
41 Width factor
50 Oblique angle
71 Text-generation flags:
2 Text is backward (mirrored in X)
4 Text is upside down (mirrored in Y)
42 Last height used
3 Primary font filename
4 Big-font filename (empty string if none)

UCS 2 UCS name


70 Standard flag values
10 Origin in WCS
11 X axis direction (in WCS)
12 Y axis direction (in WCS)

VIEW 2 View name


70 View flag:
1 If set, this View is a paper space view
40 Height
41 Width
10 Center point (a 2D point)
11 View direction from target, in WCS
12 Target point, in WCS
42 Lens length
43 Front clipping plane
44 Back clipping plane
50 Twist angle

57
Table A–5. Block and table group codes by entity (continued)

Entity type Group codes Meaning

VIEW 71 View mode—same values as the VIEWMODE system variable


(continued)

VPORT 1 Vport name (might not be unique: all Vports in the current
configuration are named *ACTIVE, and the first *ACTIVE
Vport in the table is the one currently displayed)
70 Standard flag values
10 Lower-left corner (a 2D point)
11 Upper-right corner (a 2D point)
12 Center (a 2D point)
13 Snap base point (a 2D point)
14 Snap spacing (X and Y)
15 Grid spacing (X and Y)
16 Direction from target point
17 Target point
40 Height
41 Aspect ratio
42 Lens length
43 Front clipping plane
44 Back clipping
50 Snap rotation angle
51 Twist angle
68 Status field
69 ID
71 View mode—same values as the VIEWMODE system variable
72 Circle zoom percent
73 Fast zoom setting
74 UCSICON setting
75 Snap on/off
76 Grid on/off
77 Snap style

58
Table A–5. Block and table group codes by entity (continued)

Entity type Group codes Meaning

VPORT 78 Snap isopair


(continued)

59

You might also like