Request a Personalized Demo

Learn how to accurately convert your designs with Scan2CAD

  • This field is for validation purposes and should be left unchanged.
  • Join thousands of happy customers worldwide

Technical Dissection of the DXF File Format

Scan2CAD Featured Image

Earlier this month, we’ve discussed the basic overview of the DXF file – it’s a vector graphic file format; and it is mainly used to exchange drawings between CAD programs. For many users, that’s all you need to know before you start saving drawings in DXF. However, aren’t “how it’s made” documentaries and behind-the-scenes sneak peeks interesting? Even if I’m never going to program a piece of CAD software, I get a kick out of understanding how the DXF file format works. What is it about the file structure that cements the DXF’s reputation as the most compatible vector file format? How does the CAD program on my computer render a drawing from plain text instructions? Let’s break it down.

Technical Overview of a DXF File Format

Graphic File Type Vector
Colours 256
Compression None
Maximum Image Size N/A. You can control the floating-point precision of the DXF format up to 16 decimal places.
Multiple Images per file Not allowed
Numerical format ASCII and Binary
Originator Autodesk
Platform MS-DOS
Supporting applications AutoCAD, Scan2CAD, Adobe Illustrator, CorelCAD and almost any CAD software in the market

In the following paragraphs, we’ll delve into each of these fields outlined in the table above. You can click on any of the blue-coloured links in the first column to skip to that section.

DXF – a vector file format

In computer graphics, a vector file format refers to the representation of graphic entities (such as lines and polygons) by numerically specifying key points. It’s basic Mathematics, really – the vector data consists of sets of two-dimensional Cartesian coordinates, which specifies the X and Y location of points on a grid. A CAD package will then connect lines between these points to generate (or render) the final graphic image. All sorts of shapes can be created this way; complicated shapes are simply made up of smaller lines.

Maximum Image Size

You can scale a DXF file indefinitely, as the allowable precision of a floating point in DXF goes up to 16 decimal places. You can technically render images with as high a precision as 0.0000000000000001!

Setting scale by measuring the distance

Here’s a screenshot of Scan2CAD manipulating a simple vector image — you could zoom in really close (in the program) and the lines remain just as sharp. (Don’t try zooming into with this particular image file, it’s just a screenshot saved as a .jpeg!)

8-bit colour depth

The DXF file format supports 8-bit colour depths (256 colours). It stores colours using a technique called indexed colour. There is a colour palette (or an array of colours), which defines all the possible colours that the drawing can have. The individual objects in the drawing encodes colour using positions in the colour palette, rather than a full specification of its colour. This method saves a lot of memory, storage space and transmission time.

8-bit indexed colour palette

This is what an 8-bit indexed colour palette looks like!

Numerical representation of DXF

A DXF file can either be a binary or ASCII representation of a drawing file.

  1. The ASCII DXF file is a complete representation of a drawing in ASCII text form (computer speak for plain text). Try opening the DXF file using your Notepad program and you’ll see a text file that you can read and edit. Data is represented with numbers and strings of text that you can easily interpret using the specification document. Being ASCII based, the DXF file is easily edited and interchanged across a range of different platforms.
  2. The binary DXF is a smaller file that is faster to work with. Binary files are usually 25% smaller than ASCII file and can be processed almost 5 times faster. Unlike ASCII DXF files, which entail a trade-off between size and floating-point accuracy, binary DXF files preserve all of the accuracy in the drawing database. (AutoCAD Release 10 was the first version to support this form of DXF file; this means that binary DXF files cannot be read by older versions.)

The binary DXF is not to be confused with DXB (Drawing Exchange Binary), which is a related but distinct format. The DXB file is limited to a small set of entities such as line, point, circle, arc, trace, solid and polyline.

What is an ASCII file?

Compression of DXF file (or lack thereof)

DXF is an uncompressed file type. This means that every single object and element in your drawing is fully described using ASCII text. Unlike bitmap images, you cannot save the image in a lower resolution or leave out any pixels. Hence, complicated drawings can get rather large. A good rule of thumb to go by: if it’s a fairly straightforward drawing, your DXF file shouldn’t exceed 10MB. Otherwise, you’ve probably configured something wrongly.


Structure of a DXF file

The DXF is structured into sections, such as blocks, tables and entities. Every single piece of information is carefully categorized into sections and tagged with a group code. Be sure to check out our guide to the file structure of a DXF file.

Now, let’s put our new-found understanding of to the test. Here’s a drawing of a straight line, represented in the DXF file format. If you load this DXF file onto a file viewer, it will show you the straight line on your laptop screen; nothing fancy. If you’re a computer, you’d read a series of numbers and strings of text. You can take a look by opening the DXF file using the Notepad text editor. The file would look like this:
Sample of DXF File format in text form (Straight line shape)

I used the DXF specification document to identify the DXF group codes:

  • Group code 0 marks the name of the drawing, which is a line
  • 10: X coordinate of start point, which is 15.64
  • 20: Y coordinate of start point, which is 38.24
  • 11: X coordinate of end point
  • 21: Y coordinate of end point

This well-structured data serves as instructions for your CAD software package to reproduce the drawing.

Here’s another handy resource on the Internet with few more examples of shapes translated into DXF codes. As you scroll through this page, you’ll see how different shapes are described using group codes and its associated values. For example, an ellipse is described by its extrusion directions, the center point and angle.
Sample of DXF File format in text form (Ellipse shape)


Writing DXF Interface Programs

This section is really only needed if you write your own programs to process DXF files, or if you process entity information obtained by ARX applications. You don’t have to be a computer or 170 IQ to understand the DXF mechanism – it’s really quite structured and logical. It is also possible to ignore information that you don’t need and only include information that you do. Even if you omit whole sections (such as excluding the HEADER section if you don’t set header variables), you can still obtain a usable drawing. The only key thing to note is proper formatting and making sure data appears on the line where data is expected.


Join 53,482 designers and engineers who get our best articles once a week.
  • This field is for validation purposes and should be left unchanged.
No comments yet.

Leave a Reply