Laserlab, Inc.

Dxf2gbr AutoCAD to Gerber translator manual

Copyright 1991-2003, Gregory P. Benjamin, All rights reserved.


Dxf2gbr© accepts one or more AutoCAD ASCII .dxf files in DOS or UNIX format and produces a Gerber output file corresponding to each .dxf file. Each Gerber file is a low-level graphical representation of some or all of the entities in the .dxf file, and is a good, if not perfect facsimile of the input file.

Dxf2gbr© is intended for use in the production of precision photoplots and masks. These phototools are used in photochemical manufacturing processes. For more on Gerber files and aperture lists, see section 6.2 in the appendix.

Input file format

Dxf2gbr© doesn't always detect incorrectly formatted files. Dxf2gbr works with files consisting of lines of text terminated by CR-LF (DOS) or LF (UNIX) sequences only. Other forms of line termination will produce an invalid Gerber file without producing any error messages.

Dxf2gbr© skips over the "header", "tables", and "blocks" sections of all .dxf files, so it is immaterial whether these sections are present or not. This makes it possible (and a common practice) to process .dxf files produced using the "entities only" option of AutoCAD's dxfout command.

Output files

Gerber files

Dxf2gbr produces one Gerber file with a .gbr suffix for each .dxf file processed. There is a one-to-one correspondence between input .dxf and .gbr files.

The .gbr files Dxf2gbr produces are in 2.4 format, absolute, with leading zero suppression. This indicates that vector endpoints are given as 6 digit strings, with any leading zeros left off,  and an implicit decimal point between the 2nd and 3rd digits, referenced to the origin. All dimensions are in inches. This information is included in the .lap file to fully document the .gbr file and ease transfer to other parties.

Dxf2gbr aperture lists

Dxf2gbr generates a single ASCII .lap file applicable to all the Gerbers produced for a given invocation. The .lap file is a listing of the round and square apertures used in the .gbr file(s).

  Dxf2gbr selects the apertures for a conversion session automatically. The user has no direct control over the apertures chosen other than placing certain types of entities on appropriately named layers. Entities are drawn with round and square apertures exclusively. Dxf2gbr is limited to round and square shapes because they are the only ones "built-into"  modern laser photoplotters, ensuring compatibility. Round apertures range from 0.001" (1 mil.)  to 0.199" (199 mils.) in 0.25 mil. increments. Square apertures range from 1 mil. to 2.0 inches.

Error file

A file with an .err suffix is produced for each .dxf file containing errors or warning conditions detected by dxf2gbr.  Error files list the line number in the .dxf file where the error or warning condition is detected. This usually follows the actual error location, so in analyzing errors it is necessary to scan backward through the .dxf file a few lines to find the source.

Only the first 50 errors or warnings encountered are listed in the .err file. Processing continues until the entire .dxf file is processed, and the total number of errors and warnings detected is appended to the end.

AutoCAD entities

Dxf2gbr recognizes the following items when they are encountered in the "entities" section of a .dxf file:

AutoCAD entities recognized by Dxf2gbr
AutoCAD Entity Description Solid Filled
Arc segment of circle No
Circle open ring No
Line straight path between two points No
Polyline, width = 0 similar to line or arc No
Polyline, width > 0 line or arc with a specific width, end shape Yes
Solid arbitrary three or four-vertex polygon Yes
Text string of ASCII characters No
Trace four-vertex parallelogram, similar to solid Yes

4.1 Conversion strategy

Dxf2gbr attempts to minimize the size of the Gerber file it produces for any given .dxf   file. At the same time, it attempts to faithfully represent the AutoCAD entities it encounters. Because these two goals often conflict, tradeoffs have been made. The tradeoffs are based on hundreds of customer supplied AutoCAD   files covering a broad range of applications in the electronics industry. Where it is easy to do so, and ignoring  4th place positional and 0.25 mil dimensional rounding, Dxf2gbr produces a lossless, perfect translation of AutoCAD entities. These include horizontal and vertical rectangles, (fat polylines, solids, and traces), and "donuts" ( a type of closed polyline arc).

4.2    Entity representation

Dxf2gbr divides polylines into two classes and three sub-classes classes for a total of six cases. The classes are Zero-width and Non-zero-width or “fat”. The sub-classes are Single-segment, open multi-segment, and closed multi-segment polylines.

4.3    Outlined, unfilled entities

These entities include Arcs, Circles, Lines, and zero-width Polylines. Entities of this type are drawn using a 5.25 mil round aperture unless the layer they are on has a name of the form PENxxxMIL, where xxx is a 3 digit number between 001 and 199. For example, all outlined, unfilled entities drawn on a layer named PEN017MIL are drawn using a 17 mil round aperture. This is useful for hatching odd-shaped areas.

The true path of the line is coincident with the center of the aperture. This means the line in the Gerber file will "spill-out" equally on either side, and past the endpoints of the line seen in AutoCAD.   This is so because these entities are "pure" 1-dimensional items in AutoCAD but are translated into 2-dimensional shapes by Dxf2gbr. Arcs, polyline arcs, and circles are translated into a series of short straight vector segments. Each complete circle is translated using 72 segments (5 steps). Technically, circles are translated to regular 72-sided polygons. Arcs are formed using a number of segments proportional to the fraction of  a circle they span.


Figure 1. Arc path and fill


Arcs are distinct from Polyline Arcs.  The true path of the arc is coincident with the center of the aperture. The left-hand side of figure 1 depicts the arc as drawn in AutoCAD. The right-hand side of the figure is bounded and hatched to show the path of the round aperture Dxf2gbr uses.


Circles are drawn using a round aperture. The center of the aperture coincides with the circumference of the circle. The circle is not filled, and appears in the Gerber file as a ring. The circular shape is approximated by the use of short line vectors.


Lines are drawn using a round aperture regardless of line orientation. . The center of the aperture coincides with the center of the line. No compensation is made for "pen" diameter, so the plotted line will be equal to the true length of the line plus the pen diameter (half a diameter at each end).


All text is drawn using the "romans.shx" font with an obliquing angle of 0. Text rotation and mirroring (text backwards), and text width factors are implemented, but all other style and text attributes are ignored without complaint. The text is output regardless of the attributes it has. The aperture size is chosen automatically, and is proportional to the text height.

Zero-width POLYLINE

These are drawn in the same manner as conventional lines. See “LINE” in section 4.3.3 above.

Filled entities

Filled entities include polylines with segment widths greater than zero, SOLIDs, and TRACEs. Polylines may consist of or contain one or more polyline-ARC and tapered segments. Each of these entities, with the exception of polyline-ARC segments are decomposed into three and four vertex polygons. Analysis of these polygons is done to determine the best way to fill them. if the shape is rectangular and all of the sides are orthogonal, a square aperture is used to fill the rectangle with a single vector. Rectangular or arbitrary 3 and 4-sided polygons having one or more non-orthogonal sides are approximated in the .gbrfile. This is also true of arcs, circles, and single or multi-segmented polylines. Solid entities of this type are drawn with an inset border using a 0.002" (2 mil.) round pen. The area within the border is filled with a series of parallel strokes using a 0.004" (4 mil.) round pen. Because the smallest pen used to form features is 2 mils, squared-off corners in the AutoCAD drawing have a 0.001" (1 mil) radius in the .gbr file.


Donuts are not .dxf entities. They are closed polyline arcs created by use of the “donut” command. See section below.

Filled or “fat” POLYLINE

Dxf2gbr draws fat polylines at exactly the same width they appear in AutoCAD.

Single segment “fat” POLYLINE

Single-segment polylines are subdivided into open and closed varieties. If a closed single-segment polyline is encountered it is checked to see if it matches the pattern for a "donut". When Dxf2gbr encounters a donut, it is flashed as a solid circle with the same outer diameter as the donut. If the donut has an inner diameter greater than 1 mil, the entity is drawn as a ring in the same manner as a circle, with the aperture diameter equal to the difference between the inner and outer diameters.

If the single-segment polyline is open and is a polyline arc segment it is drawn as an arc segment with rounded ends. A round aperture with a diameter equal to the width of the segment is used. This causes a projection past each end of the arc equal to one-half the aperture diameter. If the single-segment polyline is open and straight, it is drawn with squared-off ends.

Open multi-segment

Figure 2. Multi-segment "fat" polylines

The first and last segments of an open multi-segment polyline are filled to mimic the squared-off ends of AutoCAD "fat" polylines. The translation is not perfect because the corners will have a .001” (1 mil.) radius that isn’t in the original AutoCAD drawing. Segments internal to a polyline are drawn using a round aperture unless both the prior and current segments are horizontal or vertical. When a round aperture is used, rounded outside corners are produced at vertices instead of the mitered corners AutoCAD displays. If both the prior and current segments are horizontal or vertical, their common vertex is mitered to produce a squared-off corner in the same manner AutoCAD does. Figure 2 illustrates rounded outside corners and the fact that horizontal and vertical polyline ends are faithfully reproduced.

Each arc segment encountered is drawn using a round aperture with the center of the aperture corresponding to the endpoints of the arc. The aperture diameter is equal to the polyline arc width. Bear in mind that polyline arc segments and conventional arcs are treated differently.

closed multi-segment

Closed multi-segment polylines are drawn in a manner similar to open multi-segmented ones, but no effort is made to accurately reproduce the ends of the polyline because there are none. Instead, a loop is formed by adding an additional line segment between the first and last vertex.


Solids are filled polygons with 3 or 4 vertices. Those with 3 vertices are triangles. An error message is produced if the interior angle formed at any vertex is less than 10 degrees, and in the case of solids with 4 vertices, if the vertices are arranged in a "bow-tie" configuration. Solids are filled either with a series of strokes of a small aperture, or if rectangular, and sides parallel to the horizontal and vertical axes, with one or more strokes of a square aperture.


Traces are filled as they appear in AutoCAD. Traces are functionally identical to solids, but entered differently. Because each segment of a trace is a separate entity, and Dxf2gbr processes each entity in isolation, there is a zero-width gap where two segments meet. To ensure that no gap appears on the photo plotted film, the size of the apertures used may need enlargement by 0.25 mil. For example, a 2.0 mil round aperture should be replaced with a 2.25 mil round. See the section on solids for error conditions.

Error handling

There are two classes of fault conditions detected by dxf2gbr. Errors and Warnings. Error conditions result in truncated .gbr output. Warnings have no effect on processing, but are flagged to warn the operator of  malformed entities in the .dxf file. The .err file for a given .dxf file can be useful in tracking the cause of  translation problems because each error is annotated with the place in the input .dxf file it was detected.


Error messages

The error message, "Don't know about 'X', entity skipped." is produced when anything other than one of the items above is found in the .dxf file. This means that blocks, points, 3-D faces, etc. are flagged as errors.

Gerber format overview

A Gerber image consists of a series of point-to-point pen-strokes and "flashes" (instantiations of an arbitrary shape at a specific location). The Gerber file does not contain any information about the pens used other than referencing a  specific pen by its identifying number. Linked with each Gerber file (or group of related Gerber files) is a table correlating the pens' identifying number, shape, and size termed an aperture list.

Gerber files contain lists of pen-stroke (vector) endpoints and "flash" locations. These numbers lack an explicit decimal point. The number format indicates the decimal point position in a string of numbers. For instance, the string 12345 in 2.4, leading zero suppressed format indicates 1.2345”. 


horizontal rule

Back to AutoCAD to Gerber page

top of page

Laserlab Home Page

Copyright© 1998-2017 Laserlab, Inc.
Last modified on Tuesday, March 9, 2004 at 9:35 PM

Check this page for XHTML 1.0 strict compliance.

Check this page for CSS compliance.