home *** CD-ROM | disk | FTP | other *** search
- THE DXF FORMAT
- **************
- The DXF file (Drawing Interchange File) is an ASCII text file with a file
- type of ".dxf" and specially formatted text. The overall organisation 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.
-
- 2. TABLES SECTION -
- This section contains definitions of named items
- - Linetype (LTYPE) table
- - Layer table
- - Style table
- - View table
-
- 3. BLOCKS SECTION -
- This section contains Block Definition entities describing the
- entities comprising each Block in the drawing.
-
- 4. ENTITIES SECTION -
- This section contains the drawing entities, including any Block
- references.
-
- 5. END OF FILE
-
- A DXF file is composed of multiple 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" format (ie, right
- justified and blank filed in a three character field). The second line of
- the group is the 'group value', in a formatwhich depends on the type of
- the group as specified by the group code.
-
- The specific assignment of group codes depends on the item being described
- in the file. However the type of the value in this group supplies is derived
- from the group code in the following way:
-
- Group Code Range Following Value
-
- 0 - 9 String
- 10 - 59 Floating point
- 60 - 79 Integer
- 999 Comments within DXF file
-
- The appearance of values in the DXF file is not affected by the settings of
- the UNITS command; coordinates are always represented as decimal (or possibly
- scientific notation if very large) numbers and angles are always represented
- in decimal degrees with zero degrees to the east of the origin.
-
- Entites, table entries, and file separators are always introduced with a 0
- group code followed by a name descibing the item.
-
-
- GROUP CODES
- ***********
- Group codes are used both to indicate the type of value of the group and to
- indicate the general use of the group. The specific function of the group
- 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.
-
- 0 Identifies the start of an entity, table entry or file separator
- The text value that follows indicates which
- 1 The primary text value of an entity
- 2 A name; Attribute tag, Block name etc.
- 3-5 Other textual or name values
- 6 Line type name (fixed)
- 7 Text style name (fixed)
- 8 Layer name (fixed)
- 9 Variable name identifier (used only in HEADER section of DXF file)
-
- 10 Primary X coordinate (start point of a Line or Text entity, centre
- of a Circle etc.)
- 11-18 Other X coordinates
- 20 Primary Y coordinate. 2n values always correspond to 1n values and
- follow them in a file.
- 21-28 Other Y coordinates
- 30 Primary Z coordinate. 3n values always correspond to 1n and 2n
- values and follow them in a file.
- 31-36 Other Z coordinates (future)
- 38 The entity's elevation if nonzero (fixed)
- 39 The 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 Colour number (fixed)
- 66 "Enities follow" flag (fixed)
- 70-78 Integer values such as repeat counts, flag bits, or modes
-
- 999 Used to include comments (DXFIN ignores the following line)
-
- The DXF file is subdivided into four sections. File separator groups are
- used to delimit these file sections. The following is an example of a void
- DXF file where only the section markers and table headers are present.
-
- 0
- SECTION (Begin HEADER section)
- 2
- HEADER
- <<<< Header variables go here >>>>
- 0
- ENDSEC (End HEADER section)
- 0 (Begin TABLES section)
- SECTION
- 2
- TABLES
- 2
- LTYPE
- 70
- (Line type table maximum item count)
- <<<< Line type items go here >>>>
- 0
- ENDTAB
- 0
- TABLE
- 2
- LAYER
- 70
- (Layer table maximum item count)
- <<<< Layer table items go here >>>>
- 0
- ENDTAB
- 0
- TABLE
- 2
- STYLE
- 70
- (Text style table maximum item count)
- <<<< Text style table items go here >>>>
- 0
- ENDTAB
- 0
- TABLE
- 2
- VIEW
- 70
- (View table maximum item count)
- <<<< View table type items go here >>>>
- 0
- ENDTAB
- 0
- ENDSEC (End TABLES section)
- 0 (Begin BLOCKS section)
- SECTION
- 2
- BLOCKS
- <<<< Block definition entities go here >>>>
- 0
- ENDSEC (End BLOCKS section)
- 0 (Begin ENTITIES section)
- SECTION
- 2
- ENTITIES
- <<<< 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. These variables are set with various commands and are the
- type of information displayed by the STATUS command. Each variable is
- specified in the header section by a 9 group giving its name, followed by
- groups that supply its value.
-
- The header variables, the groups that follow and their meanings are as
- follows:
-
- $ACADVER 1 (The AutoCAD drawing database version number)
- $ANGBASE 50 (Angle 0 direction)
- $ANGDIR 70 (1 = clockwise, 0 = counterclockwise)
- $ATTMODE 70 (Attribute visibility: 0 = none, 1 = normal, 2 = all)
- $AUNITS 70 (Units format for angles)
- $AUPREC 70 (Units precision for angles)
- $AXISMODE 70 (Axis on if nonzero)
- $AXISUNIT 10 20 (Axis X and Y spacing)
- $BLIPMODE 70 (Blip mode on if nonzero)
- $CECOLOR 62 (Entity colour 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)
- $COORDS 70 (0 = static, 1 = continuous update, 2 = "d<a")
- $DIMALT 70 (Alternate unit dimensioning performed if nonzero)
- $DIMALTD 70 (Alternate unit precision, number of decimal places)
- $DIMALTF 40 (Alternate unit scale factor)
- $DIMAPOST 1 (Alternate text suffix)
- $DIMASO 70 (Associative dimensioning mode 1 = on, 0 = off)
- $DIMASZ 40 (Dimensioning arraow size)
- $DIMBLK 2 (Arrow block name)
- $DIMCEN 40 (Size of centre marks/lines)
- $DIMDLE 40 (Dimension line extension)
- $DIMDLI 40 (Dimension line increment)
- $DIMEXE 40 (Extension line extension)
- $DIMEXO 40 (Extension line offset)
- $DIMLFAC 40 (Linier measurements scale factor)
- $DIMLIM 70 (Dimension limits generated if nonzero)
- $DIMPOST 1 (General text suffix)
- $DIMRND 40 (Rounding value for dimension distances)
- $DIMSCALE 40 (Overall dimensioning scale factor)
- $DIMSE1 70 (First extension line suppressed if nonzero)
- $DIMSE2 70 (Second extension line suppressed if nonzero)
- $DIMSHO 70 (Update dimension entities while dragging if nonzero)
- $DIMTAD 70 (Text above dimension line if nonzero)
- $DIMTIH 70 (Text inside horizontal if nonzero)
- $DIMTM 40 (Minus tolerance)
- $DIMTOH 70 (Text outside horizontal if nonzero)
- $DIMTOL 70 (Dimension tolerances generated if nonzero)
- $DIMTP 40 (Plus tolerance)
- $DIMTSZ 40 (Dimensioning ticksize, 0 = no ticks)
- $DIMTXT 40 (Dimensioning text height)
- $DIMZIN 70 (Include zero inches in text if nonzero)
- $DRAGMODE 70 (0 = off, 1 = on, 2 = auto)
- $DRAGP1 70 (Regen-drag input sampling rate)
- $DRAGP2 70 (Fast-drag input sampling rate)
- $ELEVATION 40 (Current elevation set by ELEV commannd)
- $EXTMAX 10 20 (Drawing extents upper right corner)
- $EXTMIN 10 20 (Drawing extents lower left corner)
- $FASTZOOM 70 (0 = off, 1 = on)
- $FILLETRAD 40 (Fillet radius)
- $FILLMODE 70 (Fill mode on if nonzero)
- $GRIDMODE 70 (Gridmode on if nonzero)
- $GRIDUNIT 10 20 (Grid X and Y spacing)
- $HIGHLIGHT 70 (1 = highlight selected objects, 0 = don't highlight)
- $INSBASE 10 20 (Insertion base set by BASE command)
- $LIMCHECK 70 (Nonzero if limits checking is on)
- $LIMMAX 10 20 (Drawing limits upper right corner)
- $LIMMIN 10 20 (Drawing limits lower left corner)
- $LTSCALE 40 (Global linetype scale)
- $LUNITS 70 (Units format for coordinates and distances)
- $LUPREC 70 (Units precision for coordinates and distance)
- $MENU 1 (Name of menu file)
- $MIRRTEXT 70 (Mirror text if nonzero)
- $ORTHOMODE 70 (Ortho mode on if nonzero)
- $OSMODE 70 (Running object snap mode)
- $PDMODE 70 (Point display mode)
- $PDSIZE 40 (Point display size)
- $PLINEWID 40 (Default polyline width)
- $QTEXTMODE 70 (Quick text mode if nonzreo)
- $REGENMODE 70 (RegenAuto mode on if nonzero)
- $SKETCHINC 40 (Sketch record increment)
- $SKPOLY 70 (0 = sketch lines, 1 = sketch polylines)
- $SNAPANG 50 (Snap grid rotation angle)
- $SNAPBASE 10 20 (Snap grid base point)
- $SNAPISOPAIR 70 (Isometric plane 0 = left, 1 = top, 2 = right)
- $SNAPMODE 70 (Snap mode on if nonzero)
- $SNAPSTYLE 70 (0 = standard, 1 = isometric)
- $SNAPUNIT 10 20 (Snap grid X and Y spacing)
- $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)
- $TRACEWID 40 (Default trace width)
- $USRTIMER 70 (0 = timer off, 1 = timer on)
- $VIEWCTR 10 20 (Centre of current view on screen)
- $VIEWDIR 10 20 30 (Current viewpoint set by VPOINT command)
- $VIEWSIZE 40 (Height of current view on screen)
-
- The date / time variables ($TDCREATE and $TDUPDATE) are output as real
- numbers in the format:
-
- <Julian date>.<Fraction>
-
- The elapsed time variables ($TDINDWG and $TDUSRTIMER) have a similar format:
-
- <Number of days>.<Fraction>
-
-
- TABLES SECTION
- **************
- The Tables section of the DXF file contains up to four tables each of which
- in turn contains a variable number of table entries. The tables always
- appear in the order given above (Ltype, Layer, Style, View). Each table in
- the TABLES section is introduced with a 0 group with the label "TABLE".
- This is followed with a 2 group naming the table ("LTYPE", "LAYER", "STYLE"
- or "VIEW"), and a 70 group that specifies the maximum number of table
- entries that may follow. The tables in a drawing may contain deleted items
- but these are not written to a DXF file.Thus the actual number of tables may
- be less than the number given in the 70 group, so the count cannot be used
- as an index. It is provided so additional programs can allocate an array in
- advance to hold all the table items which follow.
-
- Following the header for each table are the table entries. Each table item
- consists of a 0 group identifying the item type (same as the table name,
- eg. "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 table
- below), 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 following are groups used for the each type of table item. All groups
- are present for each table item.
-
- LTYPE 3 (Descriptive text for linetype),
- 72 (Alignment code),
- 73 (Number of dash line items),
- 40 (Total pattern length),
- 49 (Dash length 1),
- 49 (Dash length 2),....
-
- LAYER 62 (Colour number, negitive if layer is off),
- 6 (Linetype name).
- The 1 bit is set in the 70 group flags if the layer is frozen
-
- STYLE 40 (Fixed text height; 0 if not fixed),
- 41 (Width factor),
- 50 (Obliquing angle),
- 71 (Text generation flags),
- 42 (Last height used),
- 3 (Primary font file name),
- 4 ("Bigfont" file name; blank if none)
- If the third bit (4) is set in the 70 group flags, this is
- a vertically orientated text style.
-
- A STYLE table item is used to record shape file LOAD requests also.
- In this case the first bit (1) is set in the 70 group flags and
- only the 3 group (shape file name) is meaningful. (All other groups
- are output, however).
-
- VIEW 40 41 (View height and width)
- 10 20 (View centre point)
- 11,21,31 (View direction from the origin)
-
-
- BLOCKS SECTION
- **************
- The BLOCKS section of the DXF file contains all the Block Definitions.
- This section contains all the entities that make up the Blocks used in the
- drawing. The format of the entities in this section is identical to those
- in the ENTITIES section described below, so refer to that section for
- details. All entities in the BLOCKS section appear between the BLOCK and
- ENDBLK entities. BLOCK and ENDBLK only appear in the BLOCKS section. Block
- definitions are never nested (ie. no BLOCK or ENDBLK entity appears within
- another BLOCK-ENDBLOCK pair).
-
-
- ENITIES SECTION
- ***************
- Entity items appear in both the BLOCK and ENTITIES sections of the DXF file.
- The appearance of the entities in the two sections is identical.
- The following gives the format of each entity as it appears in the file.
- Some groups that define an entity always appear and some are optional and
- appear only if they differ from their default values. In the following
- discussion, groups that always occur are given by their group number and
- function, while optional groups are indicated by "-optional N" following
- the group desciption. "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 the groups that make
- up an entity is indicated by the next 0 group, beginning the next entity or
- indicating the end of the section.
-
- Remember a DXF file is a complete representation of the drawing database,
- and that as AutoCAD is further enhanced new groups will be added to entities
- to accommodate additional features. Writing your DXF processing program in
- a table driven way, making no assumptions about the orders of groups in an
- entity, and ignoring any groups not presently defined, will make it much
- easier to accommodate DXF files from future releases of AutoCAD.
-
- Each entity begins with a 0 group identifying the entity type. The name for
- the entities are given in the table that follows. 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 colour associated with it.
- The following groups are included only if the entity has non default values
- for these properties.
-
- 6 Linetype name (if not "BYLAYER"). the special name "BYBLOCK"
- indicates a floating line type.
- 38 Elevation (if nonzero)
- 39 Thickness (if nonzero)
- 62 Colour number (if not "BYLAYER"). 0 indicates the "BYBLOCK"
- (floating) colour.
-
- The rest of the groups that make up an entity are as follows:
-
- LINE 10 20 (start point)
- 11 21 (end Point)
-
- POINT 10 20
-
- CIRCLE 10 20 (centre)
- 40 (radius)
-
- ARC 10 20 (centre)
- 40 (radius)
- 50 (start angle)
- 51 (end)
-
- TRACE 10 20 11 21 12 22 13 23
- (Four points defining the corners of the trace)
-
- SOLID 10 20 11 21 12 22 13 23
- (Four points defining the corners of the solid. If the solid
- has only 3 sides, then the coordinates 12 22, 13 23 are equal)
-
- TEXT 10 20 (insertion point)
- 40 (height)
- 1 (text value)
- 50 (rotation angle -optional 0)
- 41 (relative X value -optional 1)
- 51 (obliquing angle -optional 0)
- 7 (text style name -optional "STANDARD")
- 71 (text generation flags -optional 0)
- 72 (justification type -optional 0)
- 11 21 (alignment point -optional, appears only if the
- 72 group is present and nonzero)
-
- SHAPE 10 20 (insertion point)
- 40 (size)
- 50 (rotation angle -optional 0)
- 41 (relative X scale factor -optional 1)
- 51 (obliquing angle -optional 0)
-
- BLOCK 2 (Block name)
- 70 (Block type flags) Appears only in BLOCK section
- 10 20 (Block base point)
-
- ENDBLK No groups Appears only in BLOCK section
-
- INSERT 66 ("Attributes follow" flag -optional 0)
- 2 (Block name)
- 10 20 (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 71 (column and row counts -optional 1)
- 44 45 (column and row spacing -optional 0)
-
- ATTDEF 10 20 (text start)
- 40 (text height)
- 1 (default value)
- 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 (obliquing angle -optional 0)
- 7 (text style name -optional "STANDARD")
- 71 (text generation flags -optional 0)
- 72 (justification type -optional 0)
- 11 21 (alignment point -optional, appears only if the
- 72 group is present and nonzero)
-
- ATTRIB 10 20 (text start)
- 40 (text height)
- 1 (value)
- 2 (Attribute tag)
- 70 (Attribute flags)
- 73 (field length -optional 0)
- 50 (text rotation -optional 0)
- 41 (relative X scale factor -optional 1)
- 51 (obliquing angle -optional 0)
- 7 (text style name -optional "STANDARD")
- 71 (text generation flags -optional 0)
- 72 (justification type -optional 0)
- 11 21 (alignment point -optional, appears only if the
- 72 group is present and nonzero)
-
- POLYLINE 70 (Polyline flags)
- 40 (default starting width)
- 41 (default ending width)
-
- The flags currently have the bit values 1 (closed polyline)
- and 2 (curve fit information has been added) The default
- widths apply to any vertex that does not supply widths (see
- below)
-
- VERTEX 10 20 (location)
- 40 (starting width -optional, see above)
- 41 (ending width -optional, see above)
- 42 (bulge)
- 70 (vertex flags)
- 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 end point; a bulge of 0 indicates
- a straight segment, and a bulge of 1 is a semi-circle.
- Currently the vertex flags are 1 (extra vertex created by
- curve fitting) and 2 (curve fit tangent defined). A curve
- fit direction of 0 may be omitted from the DXF output, but
- is significant if the "tangent defined" bit is set in the
- vertex flags.
-
- SEQEND No fields
-
- This entity marks the end of the 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).
-
-
- ENTITY FLAG DEFINITIONS
- ***********************
- The entity items listed above use various "flag" values. These are integer
- codes (6x or 7x groups) that encode various pieces of information regarding
- the entity. The following paragraphs describe the meaning of the various
- flag groups used in entities. In this discussion, the term "bit coded"
- means that the flag contains various true/false values coded as the sum of
- the bit values given. If any of the group 70 flags of all symbol table
- entries (Layers, Linetypes, Text Styles, Block Definitions and Named Views)
- is set to 64, the table entry was referenced by at least one entity in the
- drawing the last time the drawing was entered to edit the drawing. This
- "referenced" flag is for the benefit of the PURGE command; it can be ignored
- by most programs that read DXF file, and need not be set by programs that
- write DXF files. Any bits not defined in the following section should be
- ignored in these fields and set to zero when constructing a DXF file.
-
-
- "Attibutes Follow" Flag
- -----------------------
- This is an optional 66 group presently used only in an INSERT entity. If
- the value that follows is 1, Attributes (ATTRIB) entities are expected
- to follow the INSERT entity.
-
-
- Attribute Flags
- ---------------
- This is a 70 group flag that appears in ATTDEF and ATTRIB entities. This is
- a bit coded field in which
- 1 means the Attribute is invisible (does not display)
- 2 means the Attribute is constant
- 4 means that verification is required on input for this Attribute
-
-
- Text Generation Flags
- ---------------------
- This is an optional 71 group that appears in TEXT, ATTDEF and ATTRIB entities.
- It is a bit coded field in which
- 2 means the text is mirrored in the X direction (eg. regular image)
- 4 means the text is upside down
-
-
- Text Justifiaction Type
- -----------------------
- This is an optional 72 group that appears in TEXT, ATTDEF and ATTRIB entities.
- Its value (NOT bit coded) indicates the text justification style used on this
- entity in which
- 0 means left justified
- 1 means baseline centered text
- 2 means right justified
- 3 means "aligned" text
- 4 means "middle" (fully) centered text
- 5 means "fit" text
-
- If this group appears with a nonzero value 11 and 21 groups will also appear
- in the entity and specify the alignment point of the text (centre, rightmost
- or second alignment point)
-
-
- Block Type Flags
- ----------------
- This is a 70 group that appears in BLKDEF entities. It is a bit coded field
- in which
- 1 means this is an "annonymous block generated by hatching or other
- internal operations
- 2 means this block has Attributes
-
-
- WRITING DXF INTERFACE PROGRAMS
- ******************************
- Writing a program that contructs a DXF file can be difficult, because you
- must maintain consistancy within the drawing in order for AutoCAD to find
- it acceptable. AutoCAD allows you to omit many items in a DXF file and
- still obtain a usable drawing. The entire HEADER section can be omitted
- if you don't need to set any header variables. Any of the tables in the
- TABLES section can be omitted if you dont' need to make any entries, and
- in fact the entire TABLES section can be dropped if nothing in it is
- required. If no Block Definitions are used in the drawing,the BLOCKS
- section can be omitted. If present however, it 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
- will be automatically created with the colour 7 (white) and the CONTINUOUS
- linetype. The EOF item must be present at the end of the file.
-
-
-
- LOADING A DXF FILE
- ******************
- A drawing interchange file can be loaded into an AutoCAD drawing by means
- of the DXFIN command. First enter the Drawing Editor with the "Create new
- drawing" task from the main menu. Then issue the DXFIN command.
-
- Command: DXFIN File name (name)
-
- Enter the name of the drawing interchange file to be loaded.
-
- In order to load a complete DXF file you must use a newly created drawing,
- before any entities have been drawn. If any errors are detected during the
- input the new drawing will be discarded. Otherwise an automatic "ZOOM All"
- is performed to set the drawing extents.
-
-