# AutoCAD DXF

OGR supports reading most versions of AutoCAD DXF and writing AutoCAD 2000 version files. The entire contents of the file is represented as a single layer named "entities". DXF is an ASCII format used for interchanging AutoCAD drawings between different software packages.

DXF files are considered to have no georeferencing information through OGR. Features will all have the following generic attributes:

- Layer: The name of the DXF layer. The default layer is "0".
- SubClasses: Where available, a list of classes to which an element belongs.
- ExtendedEntity: Where available, extended entity attributes all appended to form a single text attribute.
- Linetype: Where available, the line type used for this entity.
- EntityHandle: The hexadecimal entity handle. A sort of feature id.
- Text: The text of labels.

## Supported Elements

The following element types are supported:

- POINT: Produces a simple point geometry feature.
- MTEXT, TEXT: Produces a point feature with LABEL style information.
- LINE, POLYLINE, LWPOLYLINE: translated as a LINESTRING or POLYGON depending on whether it is closed.
- CIRCLE, ELLIPSE, ARC: Translated as a LINESTRING, interpolating the arc into line segments.
- INSERT: An attempt is made to insert the block definition as defined in the insert. Linework blocks are aggregated into a single feature with a geometry collection for the geometry. Text blocks are returned as one or more text features.
- DIMENSION: This element is exploded into a feature with arrows and leaders, and a feature with the dimensio label.

A reasonable attempt is made to preserve line color, line width, text size and orientation via OGR feature styling information when translating elements. Currently no effort is made to preserve fill styles or complex line style attributes.

The approximation of arcs, ellipses and circles as linestrings is done by splitting the arcs into subarcs of no more than a threshhold angle. This angle is the OGR_ARC_STEPSIZE. This defaults to four degrees, but may be overridden by setting the configuration variable OGR_ARC_STEPSIZE.

## Creation Issues

DXF files are written in AutoCAD 2000 format. A standard header (everything up to the ENTITIES keyword) is written from the $GDAL_DATA/header.dxf file, and the $GDAL_DATA/trailer.dxf file is added after the entities. Only one layer can be created on the output file.

Point features with LABEL styling are written as MTEXT entities based on the styling information.

Point features without LABEL styling are written as POINT entities.

LineString, MultiLineString, Polygon and MultiPolygons are written as one or more LWPOLYLINE entities, closed in the case of polygon rings. An effort is made to preserve line width and color.

The dataset creation supports the following dataset creation options:

- HEADER=filename: Override the header file used - in place of header.dxf.

- TRAILER=filename: Override the trailer file used - in place of trailer.dxf.

.