home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / FAQSYS18.ZIP / FAQS.DAT / DXFSPEC.TXT < prev    next >
Text File  |  1993-09-21  |  78KB  |  1,460 lines

  1. Appendix C
  2. Drawing Interchange and File Formats
  3.  
  4. AutoCAD can be used by itself as a complete drawing editor.  In some 
  5. applications, however, other programs must examine drawings created by AutoCAD 
  6. or generate drawings to be viewed, modified, or plotted with AutoCAD.
  7. For example, if you've made an architectural drawing with AutoCAD, using 
  8. INSERTed parts to represent windows, doors, and so on, you can process the 
  9. drawing file and produce a bill of materials of all the items used in the 
  10. drawing, or even make energy use calculations based on the area and the number 
  11. and type of windows used.  Another possible application is to use AutoCAD to 
  12. describe structures that are then sent to a large computer for finite element 
  13. structural analysis.  You can compute stresses and displace- ments and send back 
  14. information to display the deformed structure as an AutoCAD drawing.
  15. Since the AutoCAD drawing database (.dwg file) is written in a very compact 
  16. format that changes significantly from time to time as new features are added, 
  17. we do not document its format and do not recommend that you attempt to write 
  18. programs to read it directly.  To assist in interchanging drawings between 
  19. AutoCAD and other programs, a "Drawing Interchange" file format (DXF(tm)) has 
  20. been defined.  All implementations of AutoCAD accept this format and are able to 
  21. convert it to and from their internal drawing file representation.
  22. AutoCAD also supports the Initial Graphics Exchange Standard (IGES) file format.  
  23. The information comprising an AutoCAD drawing can be written out in IGES format, 
  24. and IGES files can be read and converted to AutoCAD's internal format.
  25.  
  26. C.1  ASCII Drawing Interchange (DXF) Files
  27.  
  28. This section describes AutoCAD's DXF (drawing interchange) file format and the 
  29. commands provided to read and write these files.  DXF files are stan- dard ASCII 
  30. text files.  They can easily be translated to the formats of other CAD systems, 
  31. or submitted to other programs for specialized analysis.
  32.  
  33. C.1.1  DXFOUT Command - Writing a DXF File
  34.  
  35. You can generate a drawing interchange file from an existing drawing by means of 
  36. the Drawing Editor's DXFOUT command.  The command format is:
  37.  
  38.     Command:  DXFOUT   File name <default>:  (name or RETURN)
  39.  
  40. The default name for the output file is the same as that of the current drawing, 
  41. but with a file type of ".dxf".  If you specify an explicit file name, do not 
  42. include a file type; ".dxf" is assumed.  If a file with the same name already 
  43. exists, it is deleted.  Next, DXFOUT asks what precision you want for floating-
  44. point numbers and permits output of a partial DXF file containing only selected 
  45. objects.
  46.  
  47.     Enter decimal places of accuracy (0 to 16)/Entities/Binary <6>:
  48.  
  49. The "Binary" option is described later in this appendix. If you respond with 
  50. "Entities" (or just "E"), DXFOUT will ask you to select the objects you want 
  51. written to the DXF file.  Only the objects you select will be included in the 
  52. output file - symbol tables (including Block Definitions) will not be included.  
  53. Once you've selected the desired objects, AutoCAD will prompt again for the 
  54. numeric precision:
  55.  
  56.     Enter decimal places of accuracy (0 to 16)/Binary <6>:
  57.  
  58. C.1.2  DXFIN Command - Loading a DXF File
  59.  
  60. A drawing interchange file can be converted into an AutoCAD drawing by means of 
  61. the DXFIN command.  First enter the Drawing Editor using the "Create new 
  62. drawing" task from the Main Menu.  Then issue the DXFIN com- mand.
  63.  
  64.     Command:  DXFIN   File name:  (name)
  65.  
  66. Enter the name of the drawing interchange file to be loaded.
  67.  
  68. Full DXFIN
  69.  
  70. To load a complete DXF file, you must use DXFIN in an empty drawing, before any 
  71. entities have been drawn and before any additional Block definitions, layers, 
  72. linetypes, text styles, named views, named coordinate systems, or named viewport 
  73. configurations have been created.  (If your prototype draw- ing contains any 
  74. such items, use Main Menu Task 1's "name=" technique to create a new drawing 
  75. without a prototype.)
  76. If any errors are detected during the input, the new drawing is discarded. 
  77. Otherwise, an automatic "ZOOM All" is performed to set the drawing extents.
  78.  
  79. Partial DXFIN
  80.  
  81. If the current drawing is not empty, DXFIN loads only the ENTITIES section of 
  82. the DXF file, adding the entities found there to the current drawing. In this 
  83. case, DXFIN displays the message:
  84.  
  85.     Not a new drawing -- only ENTITIES section will be input.
  86.  
  87. If errors are detected during such partial DXF input, the drawing is returned to 
  88. the state it was in before the DXFIN command.  Otherwise, the newly added 
  89. entities are drawn.
  90.  
  91. C.1.3  DXF File Format
  92.  
  93. This section describes the format of a DXF file in detail.  It contains a great 
  94. deal of technical information that you need only if you're writing your own 
  95. program to process DXF files.  Otherwise, you can skip this sec- tion.
  96. It would probably be helpful to produce a DXF file from a small drawing, print 
  97. it out, and refer to it occasionally while reading the information presented 
  98. below.
  99.  
  100. C.1.3.1  General File Structure
  101.  
  102. A Drawing Interchange File is simply an ASCII text file with a file type of 
  103. ".dxf" and specially-formatted text.  The overall organization of a DXF file is 
  104. as follows:
  105.  
  106.   1. HEADER section - General information about the drawing is found in
  107.      this section of the DXF file.  Each parameter has a variable name
  108.      and an associated value.
  109.   2. TABLES section -- This section contains definitions of named
  110.      items.
  111.        o  Linetype (LTYPE) table
  112.        o  Layer table
  113.        o  Text style (STYLE) table
  114.        o  View table
  115.        o  User Coordinate System (UCS) table
  116.        o  Viewport configuration (VPORT) table
  117.        o  Drawing manager (DWGMGR) table (for future use)
  118.   3. BLOCKS section - This section contains Block Definition entities
  119.      describing the entities comprising each Block in the drawing.
  120.   4. ENTITIES section - This section contains the drawing entities,
  121.      including any Block References.
  122.   5. END OF FILE
  123.  
  124. If you use DXFOUT's "Entities" option, the resulting DXF file will contain only 
  125. the ENTITIES and END OF FILE sections, and the ENTITIES section will reflect 
  126. only the objects you select for output.
  127. A DXF file is composed of a multiplicity of groups, each of which occupies two 
  128. lines in the DXF file.  The first line of a group is a group code, which is a 
  129. positive nonzero integer output in FORTRAN "I3" format (that is, right justified 
  130. and blank filled in a three character field).  The second line of the group is 
  131. the group value, in a format which depends on the type of the group as specified 
  132. by the group code.
  133. The specific assignment of group codes depends upon the item being described in 
  134. the file.  However, the type of the value this group supplies is derived from 
  135. the group code in the following way:
  136.                     Group code range   Following value
  137.                           0 - 9       String
  138.                          10 - 59      Floating-point
  139.                          60 - 79      Integer
  140.                         210 - 239     Floating-point
  141.                            999        Comment (string)
  142.  
  143. Thus a program can easily read the value following a group code without knowing 
  144. the particular use of this group in an item in the file.  The appearance of 
  145. values in the DXF file is not affected by the setting of the UNITS command: 
  146. coordinates are always represented as decimal (or possibly scientific notation 
  147. if very large) numbers, and angles are always repre- sented in decimal degrees 
  148. with zero degrees to the east of origin.
  149. Variables, table entries, and entities are described by a group that intro- 
  150. duces the item, giving its type and/or name, followed by multiple groups that 
  151. supply the values associated with the item.  In addition, special groups are 
  152. used for file separators such as markers for the beginning and end of sections, 
  153. tables, and the file itself.
  154. Entities, table entries, and file separators are always introduced with a 0 
  155. group code that is followed by a name describing the item.
  156.  
  157. C.1.3.2  Group Codes
  158.  
  159. Group codes are used both to indicate the type of the value of the group, as 
  160. explained above, and to indicate the general use of the group.  The spe- cific 
  161. function of the group code depends on the actual variable, table item, or entity 
  162. description.  This section indicates the general use of groups, noting as 
  163. "(fixed)" any that always have the same function.
  164.  
  165.    Group code                           Value type
  166.        0        Identifies the start of an entity, table entry, or file
  167.                 separator.  The text value that follows indicates which.
  168.        1        The primary text value for an entity.
  169.        2        A name; Attribute tag, Block name, etc.
  170.       3-4       Other textual or name values.
  171.        5        Entity handle expressed as a hexadecimal string.
  172.        6        Line type name (fixed).
  173.        7        Text style name (fixed).
  174.        8        Layer name (fixed).
  175.        9        Variable name identifier (used only in HEADER section of
  176.                 the DXF file).
  177.        10       Primary X coordinate (start point of a Line or Text
  178.                 entity, center of a Circle, etc.).
  179.      11-18      Other X coordinates.
  180.        20       Primary Y coordinate.  2n values always correspond to 1n
  181.                 values and immediately follow them in the file.
  182.      21-28      Other Y coordinates.
  183.        30       Primary Z coordinate.  3n values always correspond to 1n
  184.                 and 2n values and immediately follow them in the file.
  185.      31-37      Other Z coordinates.
  186.        38       This entity's elevation if nonzero (fixed).  Output only
  187.                 if system variable FLATLAND is set to 1.
  188.        39       This entity's thickness if nonzero (fixed).
  189.      40-48      Floating-point values (text height, scale factors, etc.).
  190.        49       Repeated value - multiple 49 groups may appear in one
  191.                 entity for variable length tables (such as the dash
  192.                 lengths in the LTYPE table).  A 7x group always appears
  193.                 before the first 49 group to specify the table length.
  194.      50-58      Angles.
  195.        62       Color number (fixed).
  196.        66       "Entities follow" flag (fixed).
  197.      70-78      Integer values, such as repeat counts, flag bits, or
  198.                 modes.
  199.  210, 220, 230  X, Y, and Z components of extrusion direction.
  200.       999       Comments
  201.  
  202. C.1.4  Comments
  203.  
  204. The 999 group code indicates that the following line is a comment string. DXFOUT 
  205. does not currently include such groups in its output file, but DXFIN honors them 
  206. and ignores the comments.  Thus, you can use the 999 group to include comments 
  207. in a DXF file you've edited.  For example:
  208.  
  209.     999
  210.     This is a comment.
  211.     999
  212.     This is another comment.
  213.  
  214. C.1.5  File Sections
  215.  
  216. The DXF file is subdivided into four sections.  File separator groups are used 
  217. to delimit these file sections.  The following is an example of a void DXF file 
  218. with only the section markers and table headers present.
  219.  
  220.       0                           (Begin HEADER section)
  221.     SECTION
  222.       2
  223.     HEADER
  224.         <<<<Header variable items go here>>>>
  225.       0
  226.     ENDSEC                        (End HEADER section)
  227.       0                           (Begin TABLES section)
  228.     SECTION
  229.       2
  230.     TABLES
  231.       0
  232.     TABLE
  233.       2
  234.     VPORT
  235.      70
  236.     (viewport table maximum item count)
  237.         <<<<viewport table items go here>>>>
  238.       0
  239.     ENDTAB
  240.       0
  241.     TABLE
  242.       2
  243.     LTYPE, LAYER, STYLE, VIEW, UCS, or DWGMGR
  244.      70
  245.     (Table maximum item count)
  246.         <<<<Table items go here>>>>
  247.       0
  248.     ENDTAB
  249.       0
  250.     ENDSEC                        (End TABLES section)
  251.       0                           (Begin BLOCKS section)
  252.     SECTION
  253.       2
  254.     BLOCKS
  255.         <<<<Block definition entities go here>>>>
  256.       0
  257.     ENDSEC                        (End BLOCKS section)
  258.       0                           (Begin ENTITIES section)
  259.     SECTION
  260.       2
  261.     ENTITIES
  262.         <<<<Drawing entities go here>>>>
  263.       0
  264.     ENDSEC                        (End ENTITIES section)
  265.       0
  266.     EOF                           (End of file)
  267.  
  268. C.1.5.1  HEADER Section
  269.  
  270. The HEADER section of the DXF file contains settings of variables associated 
  271. with the drawing.  These variables are set with various commands and are the 
  272. type of information displayed by the STATUS command.  Each variable is specified 
  273. in the header section by a 9 group giving its name, followed by groups that 
  274. supply its value.  The header variables, the groups that follow, and their 
  275. meanings are listed below.
  276. Although this list is very similar to the list of system variables in Appendix 
  277. A, the two lists are not identical.  Be sure you're referring to the proper 
  278. list.
  279.  
  280.   $ACADVER       1     the AutoCAD drawing database version number.
  281.   $ANGBASE      50     Angle 0 direction.
  282.   $ANGDIR       70     1=clockwise angles, 0=counterclockwise.
  283.   $ATTDIA       70     Attribute entry dialogues, 1 = on, 0 = off
  284.   $ATTMODE      70     Attribute visibility: 0=none, 1=normal, 2=all.
  285.   $ATTREQ       70     Attribute prompting during INSERT, 1 = on, 0 = off
  286.   $AUNITS       70     UNITS format for angles.
  287.   $AUPREC       70     UNITS precision for angles.
  288.   $AXISMODE     70     axis on if nonzero.
  289.   $AXISUNIT   10,20    axis X and Y tick spacing.
  290.   $BLIPMODE     70     blip mode on if nonzero.
  291.   $CECOLOR      62     entity color number; 0 = BYBLOCK, 256 = BYLAYER.
  292.   $CELTYPE       6     entity linetype name, or BYBLOCK or BYLAYER.
  293.   $CHAMFERA     40     first chamfer distance.
  294.   $CHAMFERB     40     second chamfer distance.
  295.   $CLAYER        8     current layer name.
  296.   $COORDS       70     0=static coordinate display, 1=continuous update,
  297.                        2="d<a" format.
  298.   $DIMALT       70     alternate unit dimensioning performed if nonzero.
  299.   $DIMALTD      70     alternate unit decimal places.
  300.   $DIMALTF      40     alternate unit scale factor.
  301.   $DIMAPOST      1     alternate dimensioning suffix
  302.   $DIMASO       70     1=create associative dimensioning, 0=draw 
  303.                        individual entities.
  304.   $DIMASZ       40     dimensioning arrow size.
  305.   $DIMBLK        2     arrow block name.
  306.   $DIMBLK1       1     first arrow block name.
  307.   $DIMBLK2       1     second arrow block name.
  308.   $DIMCEN       40     size of center mark/lines.
  309.   $DIMDLE       40     dimension line extension.
  310.   $DIMDLI       40     dimension line increment.
  311.   $DIMEXE       40     extension line extension.
  312.   $DIMEXO       40     extension line offset.
  313.   $DIMLFAC      40     linear measurements scale factor.
  314.   $DIMLIM       70     dimension limits generated if nonzero.
  315.   $DIMPOST       1     general dimensioning suffix
  316.   $DIMRND       40     rounding value for dimension distances.
  317.   $DIMSAH       70     use separate arrow blocks if nonzero.
  318.   $DIMSCALE     40     overall dimensioning scale factor.
  319.   $DIMSE1       70     first extension line suppressed if nonzero.
  320.   $DIMSE2       70     second extension line suppressed if nonzero.
  321.   $DIMSHO       70     1=Recompute dimensions while dragging,
  322.                        0=drag original image.
  323.   $DIMSOXD      70     suppress outside-extensions dimension lines if nonzero.
  324.   $DIMTAD       70     text above dimension line if nonzero.
  325.   $DIMTIH       70     text inside horizontal if nonzero.
  326.   $DIMTIX       70     force text inside extensions if nonzero.
  327.   $DIMTM        40     minus tolerance.
  328.   $DIMTOFL      70     if text outside extensions, force line between
  329.                        extensions if nonzero.
  330.   $DIMTOH       70     text outside horizontal if nonzero.
  331.   $DIMTOL       70     dimension tolerances generated if nonzero.
  332.   $DIMTP        40     plus tolerance.
  333.   $DIMTSZ       40     dimensioning tick size: 0=no ticks.
  334.   $DIMTVP       40     text vertical position.
  335.   $DIMTXT       40     dimensioning text height.
  336.   $DIMZIN       70     zero suppression for "feet & inch" dimensions.
  337.   $DRAGMODE     70     0=off, 1=on, 2=auto.
  338.   $ELEVATION    40     current elevation set by ELEV command.
  339.   $EXTMAX    10,20,30  XY drawing extents upper right corner (in WCS).
  340.   $EXTMIN    10,20,30  XY drawing extents lower left corner (in WCS).
  341.   $FILLETRAD    40     fillet radius.
  342.   $FILLMODE     70     FILL mode on if nonzero.
  343.   $FLATLAND     70     force compatibility with older versions if nonzero.
  344.   $HANDLING     70     handles enabled if nonzero.
  345.   $HANDSEED      5     next available handle.
  346.   $INSBASE   10,20,30  insertion base set by BASE command (in WCS).
  347.   $LIMCHECK     70     nonzero if limits checking is on.
  348.   $LIMMAX     10,20    XY drawing limits upper right corner (in WCS).
  349.   $LIMMIN     10,20    XY drawing limits lower left corner (in WCS).
  350.   $LTSCALE      40     global linetype scale.
  351.   $LUNITS       70     UNITS format for coordinates and distances.
  352.   $LUPREC       70     UNITS precision for coordinates and distances.
  353.   $MENU          1     name of menu file.
  354.   $MIRRTEXT     70     MIRROR text if nonzero.
  355.   $ORTHOMODE    70     ORTHO mode on if nonzero.
  356.   $OSMODE       70     running object snap modes.
  357.   $PDMODE       70     point display mode.
  358.   $PDSIZE       40     point display size.
  359.   $PLINEWID     40     default Polyline width.
  360.   $QTEXTMODE    70     quick text mode on if nonzero.
  361.   $REGENMODE    70     REGENAUTO mode on if nonzero.
  362.   $SKETCHINC    40     sketch record increment.
  363.   $SKPOLY       70     0=sketch lines, 1=sketch polylines.
  364.   $SPLFRAME     70     spline control polygon display, 1 = on, 0 = off.
  365.   $SPLINESEGS   70     number of line segments per spline patch.
  366.   $SPLINETYPE   70     spline curve type for "PEDIT Spline" (see Appendix A).
  367.   $SURFTAB1     70     number of mesh tabulations in first direction.
  368.   $SURFTAB2     70     number of mesh tabulations in second direction.
  369.   $SURFTYPE     70     surface type for "PEDIT Smooth" (see Appendix A).
  370.   $SURFU        70     surface density (for "PEDIT Smooth") in M direction.
  371.   $SURFV        70     surface density (for "PEDIT Smooth") in N direction.
  372.   $TDCREATE     40     date/time of drawing creation.
  373.   $TDINDWG      40     cumulative editing time for this drawing.
  374.   $TDUPDATE     40     date/time of last drawing update.
  375.   $TDUSRTIMER   40     user elapsed timer.
  376.   $TEXTSIZE     40     default text height.
  377.   $TEXTSTYLE     7     current text style name.
  378.   $THICKNESS    40     current thickness set by ELEV command.
  379.   $TRACEWID     40     default Trace width.
  380.   $UCSNAME       1     Name of current UCS.
  381.   $UCSORG    10,20,30  origin of current UCS (in WCS).
  382.   $UCSXDIR   10,20,30  direction of current UCS's X axis (in World coordinates).
  383.   $UCSYDIR   10,20,30  direction of current UCS's Y axis (in World coordinates).
  384.   $USERI1 - 5   70     Five integer variables intended for use by
  385.                        third-party developers.
  386.   $USERR1 - 5   40     Five real variables intended for use by
  387.                        third-party developers.
  388.   $USRTIMER     70     0=timer off, 1=timer on.
  389.   $WORLDVIEW    70     1=set UCS to WCS during DVIEW/VPOINT, 0=don't change UCS
  390.  
  391. The header variables listed below existed prior to AutoCAD Release 10 but now 
  392. have independent settings for each active viewport.  They are not output by 
  393. DXFOUT unless system variable FLATLAND is set to 1.  DXFIN honors these 
  394. variables when read from DXF files, but if a VPORT symbol table with "*ACTIVE" 
  395. entries is present (as is true for any DXF file produced by Release 10 or 
  396. higher), the values in the VPORT table entries will override the values of these 
  397. header variables.
  398.  
  399.   $FASTZOOM     70     fast zoom enabled if nonzero.
  400.   $GRIDMODE     70     grid mode on if nonzero.
  401.   $GRIDUNIT   10,20    grid X and Y spacing.
  402.   $SNAPANG      50     snap grid rotation angle.
  403.   $SNAPBASE   10,20    snap/grid base point (in UCS).
  404.   $SNAPISOPAIR  70     isometric plane: 0=left, 1=top, 2=right.
  405.   $SNAPMODE     70     snap mode on if nonzero.
  406.   $SNAPSTYLE    70     snap style: 0=standard, 1=isometric.
  407.   $SNAPUNIT   10,20    snap grid X and Y spacing.
  408.   $VIEWCTR    10,20    XY center of current view on screen.
  409.   $VIEWDIR   10,20,30  viewing direction (direction from target, in WCS).
  410.   $VIEWSIZE     40     height of view.
  411.  
  412. The date/time variables ($TDCREATE and $TDUPDATE) are output as real num- bers 
  413. in the format:
  414.     <Julian date>.<Fraction>
  415.  
  416. The elapsed time variables ($TDINDWG and $TDUSRTIMER) have a similar format:
  417.     <Number of days>.<Fraction>
  418.  
  419. C.1.5.2  TABLES Section
  420.  
  421. The TABLES section contains several tables, each of which in turn contains a 
  422. variable number of table entries. The order of the tables may change, but the 
  423. LTYPE table will always precede the LAYER table.  Each table is intro- duced 
  424. with a 0 group with the label "TABLE".  This is followed by a 2 group 
  425. identifying the particular table (VPORT, LTYPE, LAYER, STYLE, VIEW, UCS, or 
  426. DWGMGR) and a 70 group that specifies the maximum number of table entries that 
  427. may follow. The tables in a drawing may contain deleted items, but these are not 
  428. written to the DXF file.  Thus, fewer table entries may follow the table header 
  429. than are indicated by the 70 group, so don't use the count in the 70 group as an 
  430. index to read in the table.  It is provided so that your program to read DXF 
  431. files can allocate an array in advance large enough to hold all the table 
  432. entries that follow.
  433. Following this header for each table are the table entries.  Each table item 
  434. consists of a 0 group identifying the item type (same as table name, e.g., 
  435. "LTYPE" or "LAYER"), a 2 group giving the name of the table entry, a 70 group 
  436. specifying flags relevant to the table entry (defined for each table below), and 
  437. additional groups that give the value of the table entry. The end of each table 
  438. is indicated by a 0 group with the value "ENDTAB".
  439. If any table entry has bit value 64 set in its group 70 flags, the table entry 
  440. was referenced by at least one entity in the drawing the last time the drawing 
  441. editor was entered to edit this drawing.  This "referenced" flag is for the 
  442. benefit of the PURGE command; it can be ignored by most programs that read DXF 
  443. files, and need not be set by programs that write DXF files.
  444. The following are the groups used for each type of table item.  All groups are 
  445. present for each table item.
  446.  
  447.   LTYPE    3 (descriptive text for linetype), 72 (alignment code), 73
  448.            (number of dash length items), 40 (total pattern length), 49
  449.            (dash length 1), 49 (dash length 2), . . .
  450.   LAYER    62 (color number, negative if layer is off), 6 (linetype
  451.            name).  The 1 bit is set in the 70 group flags if the layer is
  452.            frozen.
  453.   STYLE    40 (fixed text height; 0 if not fixed), 41 (width factor), 50
  454.            (obliquing angle), 71 (text generation flags), 42 (last height
  455.            used), 3 (primary font file name), 4 ("bigfont" file name;
  456.            blank if none).  If the third bit (4) is set in the 70 group
  457.            flags, this is a vertically-oriented text style.
  458.            A STYLE table item is used to record shape file LOAD requests
  459.            also.  In this case the first bit (1) is set in the 70 group
  460.            flags and only the 3 group (shape file name) is meaningful
  461.            (all the other groups are output, however).
  462.            The "text generation flags" are a bit-coded field with the
  463.            following bit meanings:
  464.  
  465.                 Flag bit value                Meaning
  466.                        2        Text is backwards (mirrored in X)
  467.                        4        Text is upside down (mirrored in Y)
  468.  
  469.   VIEW     40 and 41 (view height and width), 10 and 20 (view center
  470.            point), 11, 21, 31 (view direction from target, in WCS), 12,
  471.            22, 32 (target point, in WCS), 42 (lens length), 43 and 44
  472.            (front and back clipping planes-offsets from target point), 50
  473.            (twist angle), 71 view mode (see VIEWMODE system variable
  474.            Appendix A).
  475.   UCS      10, 20, 30 (origin), 11, 21, 31 (X axis direction), 12, 22, 32
  476.            (Y axis direction).  All in World coordinates.
  477.   VPORT    10 and 20 (lower left corner of viewport; 0.0 to 1.0), 11 and
  478.            21 (upper right corner), 12 and 22 (view center point), 13 and
  479.            23 (snap base point), 14 and 24 (snap spacing, X and Y), 15
  480.            and 25 (grid spacing, X and Y), 16, 26, 36 (view direction
  481.            from target point), 17, 27, 37 (view target point), 40 (view
  482.            height), 41 (viewport aspect ratio), 42 (lens length), 43 and
  483.            44 (front and back clipping planes; offsets from target
  484.            point), 50 (snap rotation angle), 51 (view twist angle), 71
  485.            (view mode; see VIEWMODE system variable in Appendix A), 72
  486.            (circle zoom percent), 73 (fast zoom setting), 74 (UCSICON
  487.            setting), 75 (snap on/off), 76 (grid on/off), 77 (snap style),
  488.            78 (snap isopair).
  489.            The VPORT table is unique in that it may contain several
  490.            entries with the same name (indicating a multiple-viewport
  491.            configuration).  The entries corresponding to the active view-
  492.            port configuration all have the name "*ACTIVE".  The first
  493.            such entry describes the current viewport.
  494.   DWGMGR   For future use.  Fields not yet defined.
  495.  
  496. C.1.5.3  BLOCKS Section
  497.  
  498. The BLOCKS section of the DXF file contains all the Block Definitions. This 
  499. section contains the entities that make up the Blocks used in the drawing, 
  500. including "anonymous" Blocks generated by the HATCH command and by associative 
  501. dimensioning.  The format of the entities in this section is identical to those 
  502. in the ENTITIES section described below, so refer to that section for details.  
  503. All entities in the BLOCKS section appear between BLOCK and ENDBLK entities.  
  504. BLOCK and ENDBLK entities appear only in the BLOCKS section.  Block definitions 
  505. are never nested (that is, no BLOCK or ENDBLK entity ever appears within another 
  506. BLOCK-ENDBLK pair).
  507.  
  508. C.1.5.4  ENTITIES Section
  509.  
  510. Entity items appear in both the BLOCK and ENTITIES sections of the DXF file.  
  511. The appearance of entities in the two sections is identical, with the exception 
  512. that entities in the BLOCK section never have handles. The following gives the 
  513. format of each entity as it appears in the file.  Some groups that define an 
  514. entity always appear, and some are optional and appear only if they differ from 
  515. their default values.  In the following discussion, groups that always occur are 
  516. given by their group number and function, while optional groups are indicated by 
  517. "-optional N" following the group description.  "N" is the default value if the 
  518. group is omitted.
  519. Programs that read DXF files should not assume that the groups describing an 
  520. entity occur in the order given here.  The end of the groups that make up an 
  521. entity is indicated by the next 0 group, beginning the next entity or indicating 
  522. the end of the section.
  523. Remember that a DXF file is a complete representation of the drawing data- base, 
  524. and that as AutoCAD is further enhanced, new groups will be added to entities to 
  525. accommodate additional features.  Writing your DXF processing program in a 
  526. table-driven way, making no assumptions about the order of groups in an entity, 
  527. and ignoring any groups not presently defined, will make it much easier to 
  528. accommodate DXF files from future releases of AutoCAD.
  529. Each entity begins with a 0 group identifying the entity type.  The names used 
  530. for the entities are given in the table that follows.  Every entity contains an 
  531. 8 group that gives the name of the layer on which the entity resides.  Each 
  532. entity may have elevation, thickness, linetype, or color information associated 
  533. with it. If handles are enabled, every entity has a 5 group containing its 
  534. handle (as a string representing a hexadecimal number). The following groups are 
  535. included only if the entity has nonde- fault values for these properties.
  536.  
  537.   Group code                         Meaning
  538.        6      Linetype name (if not "BYLAYER").  The special name "BYBLOCK"
  539.               indicates a floating linetype.
  540.       38      Elevation (if nonzero).  Output only if system variable
  541.               FLATLAND is 1.  Otherwise, Z coordinates are supplied as
  542.               3x-groups as part of each of the entity's defining points.
  543.       39      Thickness (if nonzero).
  544.       62      Color number (if not "BYLAYER").  Zero indicates the
  545.               "BYBLOCK" (floating) color.
  546.      210,     These groups are included for each Line, Point, Circle, Shape,
  547.      220,     Text, Arc, Trace, Solid, Block Reference, Polyline, Dimension,
  548.      230      Attribute, and Attribute Definition entity if its extrusion
  549.               direction is not parallel to the World Z axis.  The indicate
  550.               the X, Y, and Z components of the entity's extrusion direction.
  551.  
  552. The rest of the groups that make up an entity item are described below. Many of 
  553. the entities include "flag" groups.  These are integer codes (6x or 7x groups) 
  554. that encode various pieces of information regarding the entity, and are specific 
  555. to the particular entity type.  In the following descrip- tions, the term "bit-
  556. coded" means that the flag contains various true/false values coded as the sum 
  557. of the bit values given.  Any bits not defined in the following section should 
  558. be ignored in these fields and set to zero when constructing a DXF file.
  559.  
  560.   LINE      10, 20, 30 (start point), 11, 21, 31 (end point).
  561.   POINT     10, 20, 30 (point), 50 (angle of X axis for the UCS in effect
  562.             when the Point was drawn -optional 0, for use when PDMODE is
  563.             nonzero).
  564.   CIRCLE    10, 20, 30 (center), 40 (radius).
  565.   ARC       10, 20, 30 (center), 40 (radius), 50 (start angle), 51 (end
  566.             angle).
  567.   TRACE     Four points defining the corners of the trace: (10, 20, 30),
  568.             (11, 21, 31), (12, 22, 32), and (13, 23, 33).
  569.   SOLID     Four points defining the corners of the solid: (10, 20, 30),
  570.             (11, 21, 31), (12, 22, 32), and (13, 23, 33).  If only three
  571.             points were entered (forming a triangular solid), the third
  572.             and fourth points will be the same.
  573.   TEXT      10, 20, 30 (insertion point), 40 (height), 1 (text value), 50
  574.             (rotation angle -optional 0), 41 (relative X scale factor
  575.             -optional 1), 51 (obliquing angle -optional 0), 7 (text style
  576.             name -optional "STANDARD"), 71 (text generation flags
  577.             -optional 0), 72 (justification type -optional 0), 11, 21, 31
  578.             (alignment point -optional, appears only if 72 group is
  579.             present and nonzero).
  580.             The "text generation flags" are a bit-coded field with mean-
  581.             ings as follows:
  582.  
  583.                  Flag bit value                Meaning
  584.                        2         Text is backwards (mirrored in X)
  585.                        4         Text is upside down (mirrored in Y)
  586.  
  587.             The "justification type" value (not bit-coded) indicates the
  588.             text justification style used on this entity, as shown in the
  589.             following table.
  590.  
  591.               Value                       Meaning
  592.                 0    Text is left justified
  593.                 1    Text is centered along its baseline
  594.                 2    Text is right justified
  595.                 3    Text is aligned between two points (height varies)
  596.                 4    Text is "middle" (fully) centered
  597.                 5    Text is fit between two points (width varies)
  598.  
  599.             If the justification is anything other than 0 (left justi-
  600.             fied), 11, 21, and 31 groups will also appear in the entity
  601.             to specify the alignment point of the text (center, right-
  602.             most, or second alignment point).
  603.             DXFOUT handles ASCII control characters in text strings by
  604.             expanding the character into a "^" (caret) followed by the
  605.             appropriate letter.  For example, an ASCII Control-G (BEL,
  606.             decimal code 7) is output as "^G".  If the text itself con-
  607.             tains a caret character, it is expanded to "^ " (caret,
  608.             space).  DXFIN performs the complementary conversion.
  609.   SHAPE     10, 20, 30 (insertion point), 40 (size), 2 (shape name), 50
  610.             (rotation angle -optional 0), 41 (relative X scale factor
  611.             -optional 1), 51 (obliquing angle -optional 0).
  612.   BLOCK     2 (Block name), 70 (Block type flags), 10, 20, 30 (Block base
  613.             point).  Appears only in BLOCKS section.  The "Block type
  614.             flags" are bit-coded, with the following bit meanings:
  615.  
  616.               Flag bit value                   Meaning
  617.                     1         This is an "anonymous" Block generated by
  618.                               hatching, associative dimensioning, or
  619.                               other internal operations.
  620.                     2         This Block has Attributes.
  621.  
  622.   ENDBLK    No groups.  Appears only in BLOCKS section.
  623.   INSERT    66 ("Attributes follow" flag -optional 0), 2 (Block name),
  624.             10, 20, 30 (insertion point), 41 (X scale factor -optional
  625.             1), 42 (Y scale factor -optional 1), 43 (Z scale factor
  626.             -optional 1), 50 (rotation angle -optional 0), 70 and 71
  627.             (column and row counts -optional 1), 44 and 45 (column and
  628.             row spacing -optional 0).
  629.             If the value of the "Attributes follow" flag is 1, a series
  630.             of Attribute (ATTRIB) entities is expected to follow the
  631.             INSERT, terminated by a sequence end (SEQEND) entity.
  632.   ATTDEF    10, 20, 30 (text start), 40 (text height), 1 (default value,
  633.             see TEXT above for handling of ASCII control characters), 3
  634.             (prompt string), 2 (tag string), 70 (Attribute flags), 73
  635.             (field length -optional 0), 50 (text rotation -optional 0),
  636.             41 (relative X scale factor -optional 1), 51 (obliquing angle
  637.             -optional 0), 7 (text style name -optional "STANDARD"), 71
  638.             (text generation flags -optional 0, see TEXT above), 72 (text
  639.             justification type -optional 0, see TEXT above)), 11, 21, 31
  640.             (alignment point -optional, appears only if 72 group is
  641.             present and nonzero).
  642.             The "Attribute flags" are a bit-coded field in which the bits
  643.             have the following meanings:
  644.  
  645.               Flag bit value                   Meaning
  646.                     1         Attribute is invisible (does not display)
  647.                     2         This is a constant Attribute
  648.                     4         Verification is required on input of this
  649.                               Attribute.
  650.                     8         Attribute is preset (no prompt during
  651.                               insertion)
  652.  
  653.   ATTRIB    10, 20, 30 (text start), 40 (text height), 1 (value, see TEXT
  654.             above for handling of ASCII control characters), 2 (Attribute
  655.             tag), 70 (Attribute flags; see ATTDEF above), 73 (field
  656.             length -optional 0), 50 (text rotation -optional 0), 41 (rel-
  657.             ative X scale factor -optional 1), 51 (obliquing angle
  658.             -optional 0), 7 (text style name -optional "STANDARD"), 71
  659.             (text generation flags -optional 0, see TEXT above), 72 (text
  660.             justification type -optional 0, see TEXT above), 11, 21, 31
  661.             (alignment point -optional, appears only if 72 group is
  662.             present and nonzero).
  663.   POLYLINE  66 ("vertices follow flag"), 70 (Polyline flags), 40 (default
  664.             starting width), 41 (default ending width), 71 and 72 (poly-
  665.             gon mesh M and N vertex counts -optional 0), 73 and 74
  666.             (smooth surface M and N densities -optional 0), 75 (smooth
  667.             surface type -optional 0).  The default widths apply to any
  668.             vertex that doesn't supply widths (see below).
  669.             The "vertices follow" flag is always 1, indicating that a
  670.             series of VERTEX entities is expected to follow the POLYLINE,
  671.             terminated by a sequence end (SEQEND) entity.  The "polyline
  672.             flags" group is a bit-coded field with bits defined as fol-
  673.             lows:
  674.  
  675.              Flag bit value                    Meaning
  676.                     1        This is a closed Polyline (or a polygon
  677.                              mesh closed in the M direction)
  678.                     2        Curve-fit vertices have been added
  679.                     4        Spline-fit vertices have been added
  680.                     8        This is a 3D Polyline
  681.                    16        This is a 3D polygon mesh.  Group 75 indi-
  682.                              cates the smooth surface type, as follows:
  683.                                0 = no smooth surface fitted
  684.                                5 = quadratic B-spline surface
  685.                                6 = cubic B-spline surface
  686.                                8 = Bezier surface
  687.                    32        The polygon mesh is closed in the N direc-
  688.                              tion
  689.  
  690.   VERTEX    10, 20, 30 (location), 40 (starting width -optional, see
  691.             above), 41 (ending width -optional, see above), 42 (bulge),
  692.             70 (vertex flags), 50 (curve fit tangent direction
  693.             -optional).  The bulge is the tangent of 1/4 the included
  694.             angle for an arc segment, made negative if the arc goes
  695.             clockwise from the start point to the end point; a bulge of 0
  696.             indicates a straight segment, and a bulge of 1 is a semicir-
  697.             cle.  The meanings of the bit-coded "vertex flags" are shown
  698.             in the following table.
  699.  
  700.              Flag bit value                    Meaning
  701.                    1         Extra vertex created by curve fitting
  702.                    2         Curve fit tangent defined for this vertex.
  703.                              A curve fit tangent direction of 0 may be
  704.                              omitted from the DXF output, but is signif-
  705.                              icant if this bit is set.
  706.                    4         Unused (never set in DXF files)
  707.                    8         Spline vertex created by spline fitting
  708.                    16        Spline frame control point
  709.                    32        3D Polyline vertex
  710.                    64        3D polygon mesh vertex
  711.  
  712.   SEQEND    No fields.  This entity marks the end of vertices (VERTEX
  713.             type name) for a Polyline, or the end of Attribute entities
  714.             (ATTRIB type name) for an INSERT entity that has Attributes
  715.             (indicated by 66 group present and nonzero in INSERT entity).
  716.   3DLINE    10, 20, 30 (start point), 11, 21, 31 (end point).
  717.   3DFACE    Four points defining the corners of the face: (10, 20, 30),
  718.             (11, 21, 31), (12, 22, 32), and (13, 23, 33).  70 (invisible
  719.             edge flags -optional 0).  If only three points were entered
  720.             (forming a triangular face), the third and fourth points will
  721.             be the same.  The meanings of the bit-coded "invisible edge
  722.             flags" are shown in the following table.
  723.  
  724.                       Flag bit value           Meaning
  725.                              1        First edge is invisible
  726.                              2        Second edge is invisible
  727.                              4        Third edge is invisible
  728.                              8        Fourth edge is invisible
  729.  
  730.   DIMENSION 2 (name of pseudo-Block containing the current dimension pic-
  731.             ture), 10, 20, 30 (definition point for all dimension types),
  732.             11, 21, 31 (middle point of dimension text), 12, 22, 32
  733.             (insertion point for clones of a dimension (for BASELINE and
  734.             CONTINUE), 70 (Dimension type; 0=rotated, horizontal, or ver-
  735.             tical; 1=aligned; 2=angular; 3=diameter; 4=radius - the value
  736.             128 is added to this field if the dimension text has been
  737.             positioned at a user-defined location rather than at the
  738.             default location), 1 (dimension text explicitly entered by
  739.             the user.  If null, the dimension measurement is drawn as the
  740.             text.  Otherwise, this text is drawn (but if it includes the
  741.             sequence "<>", the dimension measurement is drawn in place of
  742.             the "<>")), 13, 23, 33 (definition point for linear and angu-
  743.             lar dimensions), 14, 24, 34 (definition point for linear and
  744.             angular dimensions), 15, 25, 35 (definition point for diame-
  745.             ter, radius, and angular dimensions), 16, 26, 36 (point
  746.             defining dimension arc for angular dimensions), 40 (leader
  747.             length for radius and diameter dimensions), 50 (angle of
  748.             rotated, horizontal, or vertical linear dimensions).
  749.             In addition, all dimension types have an optional group (code
  750.             51) that indicates the "horizontal" direction for the Dimen-
  751.             sion entity.  This determines the orientation of dimension
  752.             text and dimension lines for horizontal, vertical and rotated
  753.             linear dimensions.  The group value is the negative of the
  754.             ECS angle of the UCS X axis in effect when the Dimension was
  755.             drawn.  In other words, the X axis of the UCS in effect when
  756.             the Dimension was drawn is always parallel to the XY plane
  757.             for the Dimension's ECS, and the angle between the UCS X axis
  758.             and the ECS X axis is a single 2D angle.  The value in group
  759.             51 is the angle from "horizontal" (the effective X axis) to
  760.             the ECS X axis.  Entity Coordinate Systems (ECS) are
  761.             described later in this section.
  762.             For all dimension types, the following groups represent 3D
  763.             WCS points, regardless of the FLATLAND setting.
  764.  
  765.                 10, 20, 30
  766.                 13, 23, 33
  767.                 14, 24, 34
  768.                 15, 25, 35
  769.  
  770.             For all dimension types, the following groups represent ECS
  771.             points, and are 2D or 3D depending on the FLATLAND setting.
  772.  
  773.                 11, 21(, 31)
  774.                 12, 22(, 32)
  775.                 16, 26(, 36)
  776.  
  777.   Linear    (13,23,33)   The point used to specify the first extension line.
  778.             (14,24,34)   The point used to specify the second extension line.
  779.             (10,20,30)   The point used to specify the dimension line.
  780.   Angular   (13,23,33) and (14,24,34)  The endpoints of the first line
  781.             (10,20,30) and (15,25,35)  The endpoints of the second line
  782.             (16,26,36)                 The point used to specify the dimen-
  783.                                        sion line arc
  784.   Diameter  (15,25,35)   The point used to pick the circle/arc to dimension
  785.             (10,20,30)   The point on that circle directly across from the
  786.                          pick point.
  787.   Radius    (15,25,35)   The point used to pick the circle/arc to dimension
  788.             (10,20,30)   The center of that circle.
  789.  
  790. Entity Coordinate Systems (ECS)
  791.  
  792. To save space in the drawing database (and in the DXF file), the points 
  793. associated with each entity are expressed in terms of its own Entity Coor- 
  794. dinate System (ECS).  The Entity Coordinate System allows AutoCAD to use a much 
  795. more compact means of representation for entities.  With ECS, the only 
  796. additional information needed to describe its position in 3D space is the 3D 
  797. vector describing the Z axis of the ECS, and the elevation value.
  798. For a given Z axis (or extrusion) direction, there is an infinite number of 
  799. coordinate systems, defined by translating the origin in 3D space and by 
  800. rotating the X and Y axes around the Z axis.  However, for the same Z axis 
  801. direction, there is only one Entity Coordinate System.  It has the follow- ing 
  802. properties:
  803.   o  Its origin coincides with the WCS origin.
  804.   o  The orientation of the X and Y axes within the XY plane are calcu-
  805.      lated in an arbitrary, but consistent manner.  AutoCAD performs
  806.      this calculation using the "arbitrary axis" algorithm described
  807.      below.
  808.  
  809. For some entities, the ECS is equivalent to the World Coordinate System and all 
  810. points (DXF groups 10-37) are expressed in World coordinates.  See the following 
  811. table.
  812.                   Entities                        Notes
  813.         LINE, POINT, 3DFACE, 3D       These entities do not lie in
  814.         Polyline, 3D Vertex, 3D       a particular plane.  All
  815.         Mesh, 3D Mesh vertex          points are expressed in
  816.                                       World coordinates.  Of these
  817.                                       entities, only Lines and
  818.                                       Points can be extruded;
  819.                                       their extrusion direction can
  820.                                       differ from the World Z axis.
  821.         CIRCLE, ARC, SOLID, TRACE,    These entities are planar in
  822.         TEXT, ATTRIB, ATTDEF, SHAPE,  nature.  All points are
  823.         INSERT, 2D Polyline, 2D       expressed in Entity coordi-
  824.         Vertex                        nates.  All these entities
  825.                                       can be extruded; their
  826.                                       extrusion direction can
  827.                                       differ from the World Z axis.
  828.         DIMENSION                     Some of a Dimension's points are
  829.                                       expressed in WCS, and some in ECS.
  830.         Others                        The remaining entities have
  831.                                       no point data and their
  832.                                       coordinate systems are
  833.                                       therefore irrelevant.
  834.  
  835. Once AutoCAD has established the ECS for a given entity, here's how it works:
  836.   o  The elevation value stored with an entity indicates how far along
  837.      the Z axis to shift the XY plane from the WCS origin to make it
  838.      coincide with the plane that the entity is in.  How much of this
  839.      is the user-defined elevation is unimportant.
  840.   o  Any 2D points describing the entity that were entered through the
  841.      UCS are transformed into the corresponding 2D points in the ECS,
  842.      which (more often than not) is shifted and rotated with respect to
  843.      the UCS.
  844.  
  845. A few ramifications of this process are:
  846.   o  You can not reliably find out what UCS was in effect when an
  847.      entity was acquired.  You can only find out where the entity is in
  848.      the current UCS if the current UCS has the same Z axis direction
  849.      as the original UCS (i.e., they both reduce to the same ECS).
  850.   o  When you enter the XY coordinates of an entity in a given UCS and
  851.      then do a DXFOUT, you probably won't recognize those XY coordi-
  852.      nates in the DXF file.  You'll have to know the method by which
  853.      AutoCAD calculates the X and Y axes in order to work with these
  854.      values.
  855.   o  The elevation value stored with an entity and output in DXF files
  856.      will be a sum of the Z coordinate difference between the UCS XY
  857.      plane and the ECS XY plane, and the elevation value that the user
  858.      specified at the time the entity was drawn.
  859.  
  860. Arbitrary Axis Algorithm
  861.  
  862. The arbitrary axis algorithm is used by AutoCAD internally to implement the 
  863. "arbitrary but consistent" generation of Entity Coordinate Systems for all 
  864. entities except Lines, Points, 3D Faces, and 3D Polylines, which contain points 
  865. in World coordinates.
  866. Given a unit-length vector to be used as the Z axis of a coordinate system, the 
  867. arbitrary axis algorithm generates a corresponding X axis for the coordinate 
  868. system.  The Y axis follows by application of the right hand rule.
  869. The method is to examine the given Z axis (also called the normal vector) and 
  870. see if it is close to the positive or negative World Z axis.  If it is, cross 
  871. the World Y axis with the given Z axis to arrive at the arbitrary X axis.  If 
  872. not, cross the World Z axis with the given Z axis to arrive at the arbitrary X 
  873. axis.  The boundary at which the decision is made was chosen to be both 
  874. inexpensive to calculate and completely portable across machines.  This is 
  875. achieved by having a sort of "square" polar cap, the bounds of which is 1/64, 
  876. which is precisely specifiable in 6 decimal fraction digits and in 6 binary 
  877. fraction bits.
  878.  
  879. In mathematical terms, the algorithm does the following (all "vectors" are 
  880. assumed to be in 3D space, specified in the World Coordinate System).
  881.     Let the given normal vector be called N.
  882.     Let the World Y axis be called Wy, which is always (0,1,0).
  883.     Let the World Z axis be called Wz, which is always (0,0,1).
  884.  
  885. We are looking for the arbitrary X and Y axes to go with the normal N. They'll 
  886. be called Ax and Ay.  N could also be called Az (the arbitrary Z axis).
  887.     If (Nx < 1/64) and (Ny < 1/64) then
  888.        Ax = Wy * N      (where "*" is the cross-product operator).
  889.     Otherwise,
  890.        Ax = Wz * N.
  891.     Scale Ax to unit length.
  892.  
  893. The method of getting the Ay vector would be:
  894.     Ay = N * Ax.
  895.     Scale Ay to unit length.
  896.  
  897. C.1.6  Writing DXF Interface Programs
  898.  
  899. Writing a program that communicates with AutoCAD via the DXF mechanism often 
  900. appears far more difficult than it really is.  The DXF file contains a seemingly 
  901. overwhelming amount of information, and examining a DXF file manually may lead 
  902. to the conclusion that the task is hopeless.
  903. However, the DXF file has been designed to be easy to process by program, not 
  904. manually.  The format was constructed with the deliberate intention of making it 
  905. easy to ignore information you don't care about while easily reading the 
  906. information you need.  Just remember to handle the groups in any order and 
  907. ignore any group you don't care about, and you'll be home free.
  908. As an example, the following is a Microsoft BASIC program that reads a DXF file 
  909. and extracts all the LINE entities from the drawing (ignoring lines that appear 
  910. inside Blocks).  It prints the endpoints of these lines on the screen.  As an 
  911. exercise you might try entering this program into your com- puter, running it on 
  912. a DXF file from one of your drawings, then enhancing it to print the center 
  913. point and radius of any circles it encounters.  This program is not put forward 
  914. as an example of clean programming technique nor the way a general DXF processor 
  915. should be written; it is presented as an example of just how simple a DXF-
  916. reading program can be.
  917.  
  918.     1000 REM
  919.     1010 REM Extract lines from DXF file
  920.     1020 REM
  921.     1030 G1% = 0
  922.     1040 LINE INPUT "DXF file name: "; A$
  923.     1050 OPEN "i", 1, A$ + ".dxf"
  924.     1060 REM
  925.     1070 REM Ignore until section start encountered
  926.     1080 REM
  927.     1090 GOSUB 2000
  928.     1100 IF G% <> 0 THEN 1090
  929.     1110 IF S$ <> "SECTION" THEN 1090
  930.     1120 GOSUB 2000
  931.     1130 REM
  932.     1140 REM Skip unless ENTITIES section
  933.     1150 REM
  934.     1160 IF S$ <> "ENTITIES" THEN 1090
  935.     1170 REM
  936.     1180 REM Scan until end of section, processing LINEs
  937.     1190 REM
  938.     1200 GOSUB 2000
  939.     1210 IF G% = 0 AND S$ = "ENDSEC" THEN 2200
  940.     1220 IF G% = 0 AND S$ = "LINE" THEN GOSUB 1400 : GOTO 1210
  941.     1230 GOTO 1200
  942.     1400 REM
  943.     1410 REM Accumulate LINE entity groups
  944.     1420 REM
  945.     1430 GOSUB 2000
  946.     1440 IF G% = 10 THEN X1 = X : Y1 = Y : Z1 = Z
  947.     1450 IF G% = 11 THEN X2 = X : Y2 = Y : Z2 = Z
  948.     1460 IF G% = 0 THEN PRINT "Line from (";X1;",";Y1;",";Z1;") to (";X2;
  949.                               ",";Y2;",";Z2;")
  950.     1470 GOTO 1430
  951.     2000 REM
  952.     2010 REM Read group code and following value
  953.     2020 REM For X coordinates, read Y and possibly Z also
  954.     2030 REM
  955.     2040 IF G1% < 0 THEN G% = -G1% : G1% = 0 ELSE INPUT #1, G%
  956.     2050 IF G% <   10 OR  G% =  999 THEN LINE INPUT #1, S$ : RETURN
  957.     2060 IF G% >=  38 AND G% <=  49 THEN INPUT #1, V : RETURN
  958.     2080 IF G% >=  50 AND G% <=  59 THEN INPUT #1, A : RETURN
  959.     2090 IF G% >=  60 AND G% <=  69 THEN INPUT #1, P% : RETURN
  960.     2100 IF G% >=  70 AND G% <=  79 THEN INPUT #1, F% : RETURN
  961.     2110 IF G% >= 210 AND G% <= 219 THEN 2130
  962.     2120 IF G% >=  20 THEN PRINT "Invalid group code";G% : STOP
  963.     2130 INPUT #1, X
  964.     2140 INPUT #1, G1%
  965.     2150 IF G1% <> (G%+10) THEN PRINT "Invalid Y coord code";G1% : STOP
  966.     2160 INPUT #1, Y
  967.     2170 INPUT #1, G1%
  968.     2180 IF G1% <> (G%+20) THEN G1% = -G1% ELSE INPUT #1, Z
  969.     2190 RETURN
  970.     2200 CLOSE 1
  971.  
  972. Writing a program that constructs a DXF file is more difficult, because you must 
  973. maintain consistency within the drawing in order for AutoCAD to find it 
  974. acceptable.  AutoCAD allows you to omit many items in a DXF file and still 
  975. obtain a usable drawing.  The entire HEADER section can be omitted if you don't 
  976. need to set any header variables.  Any of the tables in the TABLES section can 
  977. be omitted if you don't need to make any entries, and in fact the entire TABLES 
  978. section can be dropped if nothing in it is required. If you define any linetypes 
  979. in the LTYPE table, this table must appear before the LAYER table.  If no Block 
  980. Definitions are used in the drawing, the BLOCKS section can be omitted.  If 
  981. present, however, it must appear before the ENTITIES section.  Within the 
  982. ENTITIES section, you can refer- ence layer names even though you haven't 
  983. defined them in the LAYER table. Such layers will be automatically created with 
  984. color 7 and the CONTINUOUS linetype.  The EOF item must be present at the end of 
  985. file.
  986. The following Microsoft BASIC program constructs a DXF file representing a 
  987. polygon with a specified number of sides, leftmost origin point, and side 
  988. length.  This program supplies only the ENTITIES section of the DXF file, and 
  989. places all entities generated on the default layer "0".  This may be taken as an 
  990. example of a minimum DXF generation program.  Since this pro- gram doesn't 
  991. create the drawing header, the drawing limits, extents, and current view will be 
  992. invalid after performing a DXFIN on the drawing gener- ated by this program.  
  993. You can do a "ZOOM E" to fill the screen with the drawing generated.  Then 
  994. adjust the limits manually.
  995.  
  996.     1000 REM
  997.     1010 REM Polygon generator
  998.     1020 REM
  999.     1030 LINE INPUT "Drawing (DXF) file name: "; A$
  1000.     1040 OPEN "o", 1, A$ + ".dxf"
  1001.     1050 PRINT #1, 0
  1002.     1060 PRINT #1, "SECTION"
  1003.     1070 PRINT #1, 2
  1004.     1080 PRINT #1, "ENTITIES"
  1005.     1090 PI = ATN(1) * 4
  1006.     1100 INPUT "Number of sides for polygon: "; S%
  1007.     1110 INPUT "Starting point (X,Y): "; X, Y
  1008.     1120 INPUT "Polygon side: "; D
  1009.     1130 A1 = (2 * PI) / S%
  1010.     1140 A = PI / 2
  1011.     1150 FOR I% = 1 TO S%
  1012.     1160 PRINT #1, 0
  1013.     1170 PRINT #1, "LINE"
  1014.     1180 PRINT #1, 8
  1015.     1190 PRINT #1, "0"
  1016.     1200 PRINT #1, 10
  1017.     1210 PRINT #1, X
  1018.     1220 PRINT #1, 20
  1019.     1230 PRINT #1, Y
  1020.     1240 PRINT #1, 30
  1021.     1250 PRINT #1, 0.0
  1022.     1260 NX = D * COS(A) + X
  1023.     1270 NY = D * SIN(A) + Y
  1024.     1280 PRINT #1, 11
  1025.     1290 PRINT #1, NX
  1026.     1300 PRINT #1, 21
  1027.     1310 PRINT #1, NY
  1028.     1320 PRINT #1, 31
  1029.     1330 PRINT #1, 0.0
  1030.     1340 X = NX
  1031.     1350 Y = NY
  1032.     1360 A = A + A1
  1033.     1370 NEXT I%
  1034.     1380 PRINT #1, 0
  1035.     1390 PRINT #1, "ENDSEC"
  1036.     1400 PRINT #1, 0
  1037.     1410 PRINT #1, "EOF"
  1038.     1420 CLOSE 1
  1039.  
  1040. The DXFIN command is relatively forgiving with respect to the format of data 
  1041. items.  As long as a properly formatted item appears on the line on which the 
  1042. data is expected, DXFIN will accept it (of course, string items should not have 
  1043. leading spaces unless these are intended to be part of the string).  The above 
  1044. program takes advantage of this flexibility in input format, and does not go to 
  1045. great effort to generate a file appearing exactly like one generated by AutoCAD.
  1046. In the case of error loading a DXF file using DXFIN, AutoCAD reports the error 
  1047. with a message indicating the nature of the error detected and the last line 
  1048. processed in the DXF file before the error was detected.  This may not be the 
  1049. line on which the error occurred, especially in the case of such errors as 
  1050. omission of required groups.
  1051.  
  1052. C.2  Binary Drawing Interchange Files
  1053.  
  1054. The ASCII DXF file format described in the preceding sections of this appendix 
  1055. is a complete representation of an AutoCAD drawing in an ASCII text form easily 
  1056. processed by other programs.  In addition, AutoCAD can produce or read a binary 
  1057. form of the full DXF file, and accepts limited input in another binary file 
  1058. format.  These binary files are described in the following sections.
  1059.  
  1060. C.2.1  Binary DXF Files
  1061.  
  1062. The DXFOUT command provides a "Binary" option that writes binary DXF files. Such 
  1063. a file contains all of the information present in an ASCII DXF file, but in a 
  1064. much more compact form that takes, typically, 25% less file space and can be 
  1065. read and written more quickly (typically 5 times faster) by AutoCAD.  Unlike 
  1066. ASCII DXF files, which entail a trade-off between size and floating-point 
  1067. accuracy, binary DXF files preserve all of the accuracy in the drawing database.  
  1068. AutoCAD Release 10 is the first version to support this form of DXF file; it 
  1069. cannot be read by older versions.
  1070.  
  1071. A binary DXF file begins with a 22-byte sentinel consisting of:
  1072.     "AutoCAD Binary DXF<CR><LF><SUB><NUL>"
  1073.  
  1074. Following the sentinel are (group,value) pairs as in an ASCII DXF file, but 
  1075. represented in binary form.  The group code is a single-byte binary value, and 
  1076. the value that follows is one of the following:
  1077.   o  a two-byte integer with the least significant byte first and the
  1078.      most significant byte last,
  1079.   o  an eight-byte IEEE double precision floating-point number stored
  1080.      with the least significant byte first and the most significant
  1081.      byte last, or
  1082.  
  1083.   o  an ASCII string terminated by a zero (NUL) byte.
  1084.  
  1085. The type of the datum following a group is determined from the group code 
  1086. according to the same rules used in decoding ASCII DXF files.  Translation of 
  1087. angles to degrees, and dates to fractional Julian date representation, is 
  1088. performed for binary files as well as for ASCII DXF files.  The comment group, 
  1089. 999, is not used in binary DXF files.
  1090. DXFOUT writes binary DXF files with the same file type (".dxf") as for ASCII DXF 
  1091. files.  The DXFIN command automatically recognizes a binary file (by means of 
  1092. its sentinel string) and loads it.  There is no need for you to identify it as a 
  1093. binary file.
  1094. If DXFIN encounters an error in a binary DXF file, it reports the byte address 
  1095. within the file where the error was detected.
  1096.  
  1097. C.3  Binary Drawing Interchange (DXB) Files
  1098.  
  1099. The DXF file formats described earlier in this appendix are complete repre- 
  1100. sentations of an AutoCAD drawing that can be written and read by AutoCAD and 
  1101. other programs.  However, AutoShade(tm) and programs executed via the "external 
  1102. commands" facility (Appendix B) often have a need to supply simple geometric 
  1103. input to AutoCAD.  For these purposes, another file format even more compact 
  1104. than the binary DXF format is supported.  This format, called DXB (for "drawing 
  1105. interchange binary") is limited in the entities it can represent.  Furthermore, 
  1106. AutoCAD has a command to read such files, but no direct method of writing them.  
  1107. (The ADI plotter driver can plot to a file in DXB format.)
  1108.  
  1109. C.3.1  DXBIN Command
  1110.  
  1111. To load a DXB file produced by a program such as AutoShade, enter the DXBIN 
  1112. command:
  1113.  
  1114.     Command:  DXBIN
  1115.     DXB file:
  1116.  
  1117. enter the name of the file you wish to load.  Don't include a file type; ".dxb" 
  1118. is assumed.
  1119.  
  1120. C.3.2  DXB File Format
  1121.  
  1122. This information is for experienced programmers, and is subject to change 
  1123. without notice.
  1124.  
  1125. The format of a DXB file is as follows:
  1126.     Header:      "AutoCAD DXB 1.0" CR LF ^Z NUL       (19 bytes)
  1127.     Data:      . . . Zero or more data records . . .
  1128.     Terminator:  NUL                                  (1 byte)
  1129.  
  1130. Each data record begins with a single byte giving its type, followed by data 
  1131. items.  The data items have various forms of representation and encod- ing.  In 
  1132. the descriptions below, each data item is prefixed with a letter and a hyphen.  
  1133. The meaning of the letter codes is as follows:
  1134.   w-  16-bit integer, byte reversed in the standard 8086 style (least
  1135.       significant byte first, most significant byte second).
  1136.   f-  IEEE 64-bit floating-point value stored with lsb first, msb last
  1137.       (as stored by an 8087).
  1138.   l-  32-bit integer with the bytes reversed 8086-style.
  1139.   n-  Number which may be either a 16-bit integer or a floating-point
  1140.       number depending on the most recent setting of the "number mode"
  1141.       data item.  The number mode defaults to 0, signifying integers.  If
  1142.       set to 1, all n- items will be read as floating-point.
  1143.   u-  Item which is either a 32-bit integer or a floating-point number
  1144.       depending on the most recent number mode setting.  If a 32-bit
  1145.       integer, the value is scaled by multiplying it by 65536 (2^16).  If
  1146.       a floating-point value, no scaling is applied.
  1147.   a-  Item representing an angle.  If number mode is integer, this is a
  1148.       32-bit integer representing an angle in units of millionths of a
  1149.       degree (range 0 to 360,000,000).  If a floating-point number, rep-
  1150.       resents degrees.
  1151.  
  1152. In the following table, the lengths include the item-type byte and assume the 
  1153. number mode is set to zero (integer mode).  If number mode is floating- point, 
  1154. add 6 bytes to the length for each n- item present and 4 bytes for each a-, or 
  1155. u- item present.
  1156.  
  1157.         Item type        Code           Data items           Length
  1158.                        (decimal)                             (bytes)
  1159.      LINE                  1      n-fromx n-fromy               9
  1160.                                   n-tox n-toy
  1161.      POINT                 2      n-x n-y                       5
  1162.      CIRCLE                3      n-ctrx n-ctry n-rad           7
  1163.      ARC                   8      n-ctrx n-ctry n-rad          19
  1164.                                   a-starta a-enda
  1165.      TRACE                 9      n-x1 n-y1 n-x2 n-y2          17
  1166.                                   n-x3 n-y3 n-x4 n-y4
  1167.      SOLID                11      n-x1 n-y1 n-x2 n-y2          17
  1168.                                   n-x3 n-y3 n-x4 n-y4
  1169.      SEQEND               17      (none)                        1
  1170.      POLYLINE             19      w-closureflag                 3
  1171.      VERTEX               20      n-x n-y                       5
  1172.      3DLINE               21      n-fromx n-fromy n-fromz      13
  1173.                                   n-tox n-toy n-toz
  1174.      3DFACE               22      n-x1 n-y1 n-z1               25
  1175.                                   n-x2 n-y2 n-x2
  1176.                                   n-x3 n-y3 n-z3
  1177.                                   n-x4 n-y4 n-z4
  1178.      SCALE FACTOR         128     f-scalefac                    9
  1179.      NEW LAYER            129     "layername" NUL          "layername"
  1180.                                                            length + 2
  1181.      LINE EXTENSION       130     n-tox n-toy                   5
  1182.      TRACE EXTENSION      131     n-x3 n-y3 n-x4 n-y4           9
  1183.      BLOCK BASE           132     n-bx n-by                     5
  1184.      BULGE                133     u-2h/d                        5
  1185.      WIDTH                134     n-startw n-endw               5
  1186.      NUMBER MODE          135     w-mode                        3
  1187.      NEW COLOR            136     w-colornum                    3
  1188.      3DLINE EXTENSION     137     n-tox n-toy n-toz             7
  1189.  
  1190. The LINE EXTENSION item extends the last line or line extension from its "to" 
  1191. point to a new "to point".  The trace extension item similarly extends the last 
  1192. trace solid, or trace extension from its x3,y3-x4,y4 ending line to a new x3,y3-
  1193. x4,y4 line.
  1194. The SCALE FACTOR is a floating-point value by which all integer coordinates are 
  1195. multiplied to obtain the floating-point coordinates used by the actual entities.  
  1196. The initial scale factor when a file is read is 1.0.  The NEW LAYER item will 
  1197. create a layer if none exists, giving it the same defaults as the "LAYER NEW" 
  1198. command, and will set that layer as the current layer for subsequent entities.  
  1199. At the end of the DXB file load, the layer in effect before the command will be 
  1200. restored.
  1201. The BLOCK BASE item specifies the base (origin) point of a Block being cre- 
  1202. ated.  The Block base must be defined before the first entity record is 
  1203. encountered.  If DXB is not defining a Block, this specification will be 
  1204. ignored.
  1205.  
  1206. A Polyline consists of straight segments of fixed width connecting the vertices, 
  1207. except as overridden by the BULGE and WIDTH items described below. The closure 
  1208. flag should be 0 or 1; if it is 1, then there is an implicit segment from the 
  1209. last vertex (immediately before the SEQEND) to the first vertex.
  1210.  
  1211. A BULGE item, encountered between two VERTEX items (or after the last VERTEX of 
  1212. a closed Polyline), indicates that the two vertices are connected by an arc 
  1213. rather than a straight segment.  If the line segment connecting the vertices 
  1214. would have length d, and the perpendicular distance from the midpoint of that 
  1215. segment to the arc is h, then the magnitude of the BULGE is (2 * h / d).  The 
  1216. sign is negative if the arc from the first vertex to the second is clockwise.  A 
  1217. semicircle thus has a bulge of 1 (or -1).  If the number mode is 0 (integer), 
  1218. BULGE items are scaled by 216.  If the number mode has been set to floating-
  1219. point, then the floating-point value supplied is just 2*h/d (not scaled).
  1220.  
  1221. The WIDTH item indicates the starting and ending widths of the segment (straight 
  1222. or curved) connecting two vertices.  This width stays in effect until the next 
  1223. width item or the SEQEND.  If there is a WIDTH item between the POLYLINE item 
  1224. and the first VERTEX, it is stored as a default width for the Polyline; this 
  1225. will save considerable database space if the Polyline has several segments of 
  1226. this width.
  1227.  
  1228. The NUMBER MODE item controls the mode of items with types given in the table 
  1229. above as n-, a-, or u-.  If the value supplied is zero, these values will be 
  1230. integers, otherwise floating-point.  The storage and implicit scal- ing 
  1231. conventions for these values in both modes are described above.
  1232.  
  1233. LINEs and 3DLINEs share the same cells to remember the last to-point, so you 
  1234. shouldn't mix extension groups for the two entities without an initial group 
  1235. before the extension.  There is no "extension" group for 3DFACEs, as there's no 
  1236. obvious edge to extend from.
  1237.  
  1238. The "NEW COLOR" group specifies the color for subsequent entities in the DXB 
  1239. file.  The "w-colornum" word argument is in the range from 0 to 256.  0 means 
  1240. color by block, 1-255 are the standard AutoCAD colors, and 256 means color by 
  1241. layer.  A color outside the range from 0 to 256 sets the color back to the 
  1242. current entity color (you can do this deliberately, and it can be quite handy).  
  1243. The initial entity color of material added by DXBIN is the current entity color.
  1244.  
  1245. All points specified in the DXB file are interpreted in terms of the current UCS 
  1246. at the time the DXBIN command is executed.
  1247.  
  1248. C.3.3  Writing DXB Files
  1249.  
  1250. There is no direct AutoCAD command to write a DXB file, but the special "ADI" 
  1251. plotter driver can write such a file.  If you want to create a DXB file from an 
  1252. AutoCAD drawing, configure the "ADI" plotter and select its DXB file output 
  1253. option.
  1254.  
  1255. C.4  Initial Graphics Exchange Standard (IGES) Files
  1256.  
  1257. Using the commands described in this section, you can instruct AutoCAD to read 
  1258. and write IGES format interchange files.
  1259. NOTE:  The format of IGES files and the mapping performed to translate between 
  1260. AutoCAD drawing information and IGES are described in the separate AutoCAD / 
  1261. IGES Interface Specifications document (one of the items supplied when you 
  1262. return your AutoCAD license registration card).
  1263.  
  1264. C.4.1  IGESOUT Command
  1265.  
  1266. You can generate an Initial Graphics Exchange Standard (IGES) interchange file 
  1267. from an existing AutoCAD drawing by means of the Drawing Editor's IGESOUT 
  1268. command.  The command format is:
  1269.  
  1270.     Command:  IGESOUT   File name:  (name or RETURN)
  1271.  
  1272. The default name for the output file is the same as that of the current drawing, 
  1273. but with a file type of ".igs".  If you specify an explicit file name without 
  1274. including a file type, ".igs" is assumed. If a file with the same name already 
  1275. exists, it is deleted.
  1276.  
  1277. C.4.2  IGESIN Command
  1278.  
  1279. An IGES interchange file can be converted into an AutoCAD drawing by means of 
  1280. the IGESIN command.  First enter the Drawing Editor using the "Create new 
  1281. drawing" task from the Main Menu.  Then issue the IGESIN command.
  1282.  
  1283.     Command:  IGESIN   File name:  (name)
  1284.  
  1285. Enter the name of the IGES file to be loaded.
  1286.  
  1287. If a serious error is encountered, the input process is halted and an error 
  1288. message is displayed reporting where the error was found.  The partial drawing 
  1289. is not discarded.
  1290.  
  1291. C.5  Slide File Format
  1292.  
  1293. AutoCAD slide files are screen images written by the MSLIDE command and read by 
  1294. the VSLIDE command.  This section describes the format of slide files, for the 
  1295. benefit of developers who wish to incorporate support for AutoCAD slides into 
  1296. their programs.
  1297. This information is for experienced programmers, and is subject to change 
  1298. without notice.
  1299.  
  1300. The general format of a slide file is:
  1301.    1.  Header (31 bytes)
  1302.    2.  One or more data records (variable length)
  1303.  
  1304. All coordinates and sizes written to the slide file reflect the graphics area of 
  1305. the display device from which the slide was created, with point (0,0) located at 
  1306. the lower left corner of the graphics area.  For AutoCAD Release 9 and later, 
  1307. the slide file header consists of the following fields:
  1308.  
  1309.       Field       Bytes                     Description
  1310.  Id string          17   "AutoCAD Slide" CR LF ^Z NUL
  1311.  Type indicator     1    Currently set to 86 (decimal).
  1312.  Level indicator    1    Currently set to 2.
  1313.  High X dot         2    Width of the graphics area - 1, in pixels.
  1314.  High Y dot         2    Height of the graphics area - 1, in pixels.
  1315.  Aspect ratio       4    Aspect ratio (horizontal size / vertical size in
  1316.                          inches) of the graphics area, scaled by
  1317.                          10,000,000.  This value is always written with
  1318.                          the least significant byte first.
  1319.  Hardware fill      2    Either 0 or 2 (value is unimportant).
  1320.  Test number        2    A number (1234 hex) used to determine whether
  1321.                          all 2-byte values in this slide file were writ-
  1322.                          ten with the high byte first (as by Intel
  1323.                          8086-family CPUs) or the low byte first (as by
  1324.                          Motorola 68000-family CPUs).
  1325.  
  1326. Data records follow the header.  Each data record begins with a 2-byte field 
  1327. whose high-order byte is the record type.  The remainder of the record may be 
  1328. composed of 1-byte or 2-byte fields, as described in the fol- lowing table.  To 
  1329. determine whether the 2-byte fields are written with the high byte first or the 
  1330. low byte first, examine the Test number field of the header, described above.
  1331.  
  1332.      Record    Length      Meaning                Description
  1333.    type (hex)  (bytes)
  1334.     00 - 7F       8        Vector      The from-X coordinate for an
  1335.                                        ordinary vector.  From-Y, to-X,
  1336.                                        and to-Y follow in that order, as
  1337.                                        2-byte values.  The from point is
  1338.                                        saved as the last point.
  1339.     80 - FA       -       Undefined    Reserved for future use.
  1340.        FB         5     Offset vector  The low-order byte and the fol-
  1341.                                        lowing three bytes specify the
  1342.                                        endpoints (from-X, from-Y, to-X,
  1343.                                        to-Y) of a vector, in terms of
  1344.                                        offsets (-128 to +127) from the
  1345.                                        saved last point.  The adjusted
  1346.                                        from point is saved as the last
  1347.                                        point for use by subsequent vec-
  1348.                                        tors.
  1349.        FC         2      End of file   The low-order byte is 00.
  1350.        FD         6      Solid fill    The low-order byte is always
  1351.                                        zero.  The following two 2-byte
  1352.                                        values specify the X and Y coor-
  1353.                                        dinates of one vertex of a poly-
  1354.                                        gon to be solid-filled.  3 to 10
  1355.                                        such records occur in sequence.
  1356.                                        A Solid fill record with a nega-
  1357.                                        tive Y coordinate indicates the
  1358.                                        start or end of such a flood
  1359.                                        sequence.  In the start record,
  1360.                                        the X coordinate indicates the
  1361.                                        number of vertex records to
  1362.                                        follow.
  1363.        FE         3        Common      This is a vector starting at the
  1364.                           endpoint     last point.  The low-order byte
  1365.                            vector      and the following byte specify
  1366.                                        to-X and to-Y in terms of offsets
  1367.                                        (-128 to +127) from the saved
  1368.                                        last point.  The adjusted to
  1369.                                        point is saved as the last point
  1370.                                        for use by subsequent vectors.
  1371.        FF         2       New color    Subsequent vectors are to be
  1372.                                        drawn using the color number
  1373.                                        indicated by the low-order byte.
  1374.  
  1375. If a slide contains any vectors at all, a New color record will be the first 
  1376. data record.  The order of the vectors in a slide, and the order of the 
  1377. endpoints of those vectors, may vary.
  1378. For example, the following is an annotated hex dump of a simple slide file 
  1379. created on an IBM PC/AT with an IBM Enhanced Graphics Adapter.  The slide 
  1380. consists of a white diagonal line from the lower left corner to the upper right 
  1381. corner of the graphics area, a green vertical line near the lower left corner, 
  1382. and a small red rectangle at the lower left corner.
  1383.  
  1384.   41 75 74 6F 43 41        Id string ("AutoCAD Slide" CR LF ^Z NUL)
  1385.   44 20 53 6C 69 64
  1386.   65 0D 0A 1A 00
  1387.   56                       Type indicator (86)
  1388.   02                       Level indicator (2)
  1389.   3C 02                    High X dot (572)
  1390.   24 01                    High Y dot (292)
  1391.   0B 80 DF 00              Aspect ratio (14,647,307 / 10,000,000 = 1.46)
  1392.   02 00                    Hardware fill (2)
  1393.   34 12                    Test number (1234 hex)
  1394.   07 FF                    New color (7 = white)
  1395.   3C 02 24 01 00 00 00 00  Vector from 572,292 to 0,0.  572,292 becomes
  1396.                            "last" point
  1397.   03 FF                    New color (3 = green)
  1398.   0F 00 32 00 0F 00 13 00  Vector from 15,50 to 15,19.  15,50 becomes
  1399.                            "last" point
  1400.   01 FF                    New color (1 = red)
  1401.   12 FB E7 12 CE           Offset vector from 15+18,50-25 (33,25) to
  1402.                            15+18,50-50 (33,0).  33,25 becomes "last" point
  1403.   DF FE 00                 Common-endpoint vector from 33,25 to
  1404.                            33-33,25+0 (0,25).  0,25 becomes "last" point
  1405.   00 FE E7                 Common-endpoint vector from (0,25) to
  1406.                            0+0,25-25 (0,0).  0,0 becomes "last" point
  1407.   21 FE 00                 Common-endpoint vector from (0,0) to
  1408.                            0+33,0+0 (33,0).  33,0 becomes "last" point
  1409.   00 FC                    End of file
  1410.  
  1411. Old Slide Header
  1412.  
  1413. The slide format described above is that produced by AutoCAD Release 9 and 
  1414. later, and is portable among all computers running AutoCAD Release 9 or later.  
  1415. Previous versions of AutoCAD (as well as AutoShade 1.0 and AutoSketch 1.02) 
  1416. produce slides with a somewhat different header, as shown below.
  1417.  
  1418.       Field       Bytes                     Description
  1419.  Id string          17   "AutoCAD Slide" CR LF ^Z NUL
  1420.  Type indicator     1    86 (decimal).
  1421.  Level indicator    1    1 (old format).
  1422.  High X dot         2    Width of the graphics area - 1, in pixels.
  1423.  High Y dot         2    Height of the graphics area - 1, in pixels.
  1424.  Aspect ratio       8    Aspect ratio (horizontal size / vertical size in
  1425.                          inches) of the graphics area, written as a
  1426.                          floating-point number.
  1427.  Hardware fill      2    Either 0 or 2 (value is unimportant).
  1428.  Filler byte        1    Unused
  1429.  
  1430. Note that the old-format header does not contain a Test number field.  The 
  1431. floating-point aspect ratio value and all two-byte integers are written in the 
  1432. native format of the CPU used to create the file (for 8086-family CPUs, IEEE 
  1433. double-precision and low byte first).  Old-format slide files are not portable 
  1434. across machine types, but they can be read by any version of AutoCAD running on 
  1435. the same CPU type as the CPU with which the slide was created.
  1436.  
  1437. C.6  Slide Library File Format
  1438.  
  1439. This section describes the format of AutoCAD slide libraries (Release 9 and 
  1440. later), for the benefit of developers who wish to incorporate support for slide 
  1441. libraries into their programs.
  1442. This information is for experienced programmers, and is subject to change 
  1443. without notice.
  1444.  
  1445. The general format of a slide library is:
  1446.   1.  Header (32 bytes)
  1447.       "AutoCAD Slide Library 1.0" CR LF ^Z NUL NUL NUL NUL
  1448.   2.  One or more slide directory entries (36 bytes each)
  1449.   3.  One or more slides (variable length)
  1450.  
  1451. Slide directory entries have the following format:
  1452.   1.  Slide name (NUL terminated) (32 bytes)
  1453.   2.  Address of slide within library file (4 bytes)
  1454.  
  1455. The slide address is always written with the low byte first.  Each slide to 
  1456. which the directory points is a complete slide file as described in the previous 
  1457. section.  The end of the slide directory is signified by an entry with a null 
  1458. slide name (first byte is NUL).  A slide library may contain a mixture of old-
  1459. format and new-format slides.
  1460.