Drawing Interchange File Formats
DXB Files |
The DXB File Format
|
This information is for experienced programmers and is subject to change without notice.
The format of a DXB file is as follows:
Header: "AutoCAD DXB 1.0" CR LF ^Z NUL (19 bytes)Terminator: NUL (1 byte)
Each data record begins with a single byte identifying the record type, followed by data items. The data items have various forms of representation and encoding. In the following descriptions of the letter codes, each data item is prefixed with a letter and a hyphen.
w-16-bit integer, byte reversed in the standard 80x86 style the least significant byte first, and the most significant byte second).
IEEE 64-bit floating-point value stored with LSB first, MSB last (as stored by an 80x87).
32-bit integer with the bytes reversed 80x86 style.
Either a 16-bit integer or a floating-point number, depending on the most recent setting of the number mode data item. The number mode defaults to 0, signifying integers. If set to 1, all n- items will be read as floating point.
Either a 32-bit integer or a floating-point number, depending on the most recent number mode setting. If a 32-bit integer, the value is scaled by multiplying it by 65,536 (216). If a floating-point value, no scaling is applied.
An angle. If number mode is integer, this is a 32-bit integer representing an angle in units of millionths of a degree (range 0 to 360,000,000). If a floating-point number, it represents degrees.
In the following table, the lengths include the item-type byte and assume that the number mode is set to 0 (integer mode). If number mode is floating point, add 6 bytes to the length for each n- item present and 4 bytes for each a- or u- item present.
Byte length for item typesItem type |
Code (decimal) |
Data items |
Length (bytes) |
Line |
1 |
n-fromx n-fromy |
13 |
Point |
2 |
n-x n-y |
5 |
Circle |
3 |
n-ctrx n-ctry n-rad |
7 |
Arc |
8 |
n-ctrx n-ctry n-rad |
19 |
Trace |
9 |
n-x1 n-y1 n-x2 n-y2 |
17 |
Solid |
11 |
n-x1 n-y1 n-x2 n-y2 |
17 |
Seqend |
17 |
(none) |
1 |
Polyline |
19 |
w-closureflag |
3 |
Vertex |
20 |
n-x n-y |
5 |
3Dface |
22 |
n-x1 n-y1 n-z1 |
25 |
Scale factor |
128 |
f-scalefac |
9 |
New layer |
129 |
"layername" NUL |
layername |
Line extension |
130 |
n-tox n-toy |
5 |
Trace extension |
131 |
n-x3 n-y3 n-x4 n-y4 |
9 |
Block base |
132 |
n-bx n-by |
5 |
Bulge |
133 |
u-2h/d |
5 |
Width |
134 |
n-startw n-endw |
5 |
The line extension item extends the last line or line extension from its To point to a new To point. The trace extension item extends the last trace solid, or trace extension from its x3,y3-x4,y4 ending line to a new x3,y3--x4,y4 line.
The scale factor is a floating-point value by which all integer coordinates are multiplied to obtain the floating-point coordinates used by the entities. The initial scale factor when a file is read is 1.0. The new layer item creates a layer if none exists, giving the new layer the same defaults as the LAYER New command, and sets that layer as the current layer for subsequent entities. At the end of the DXB file load, the layer in effect before the command is restored.
The block base item specifies the base (origin) point of a created block. The block base must be defined before the first entity record is encountered. If DXB does not define a block, this specification is ignored.
A polyline consists of straight segments of fixed width connecting the vertices, except as overridden by the bulge and width items. The closure flag should be 0 or 1; if it is 1, there is an implicit segment from the last vertex (immediately before the Seqend) to the first vertex.
A bulge item, encountered between two vertex items (or after the last vertex of a closed polyline), indicates that the two vertices are connected by an arc rather by than a straight segment. If the distance between the vertices has length d, and the perpendicular distance from the midpoint of that segment to the arc is h, then the magnitude of the bulge is (2 * h / d). The sign is negative if the arc from the first vertex to the second is clockwise. A semicircle thus has a bulge of 1 (or -1). If the number mode is 0 (integer), bulge items are scaled by 2 16. If the number mode has been set to floating point, then the floating-point value supplied is 2*h/d (not scaled).
The width item indicates the starting and ending widths of the segment (straight or curved) connecting two vertices. This width stays in effect until the next width item or the seqend. If there is a width item between the polyline item and the first vertex, it is stored as a default width for the polyline. This saves considerable database space if the polyline has several segments of this width.
The number mode item controls the mode of items with types given in the preceding table as n-, a-, or u-. If the value supplied is 0, these values will be integers; otherwise, they are floating point.
To remember the last to-point, lines share the same cells, so do not mix extension groups for the two entities without an initial group before the extension. There is no extension group for 3D faces, because there is no obvious edge to extend from.
The new color group specifies the color for subsequent entities in the DXB file. The w-colornum word argument is in the range from 0 to 256. 0 means color by block, 1-255 are the standard AutoCAD colors, and 256 means color by layer. A color outside the range from 0 to 256 sets the color back to the current entity color (you can do this deliberately, and it can be quite useful). The initial entity color of material added by DXBIN is the current entity color.
All points specified in the DXB file are interpreted in terms of the current UCS at the time that the DXBIN command is executed.