How to Fix the ill Octagonal Gerber Aperture Macro by Proteus
If you use octagonal pads (e.g. those chamfered rectangular pads) in Proteus, some versions of Proteus may export defective Gerber aperture macros for these graphic elements. See the figure below.
This aperture is made with Gerber’s outline (code 4) macro, for details please refer to section "184.108.40.206 Outline, Code 4" in the "The Gerber Layer Format Specification".
According to the specification:
An outline primitive is an area defined by its outline or contour. The outline is a polygon, consisting of linear segments only, defined by its start vertex and n subsequent vertices. The outline must be closed, i.e. the last vertex must be equal to the start vertex. ... As the outline must be closed the last coordinates must be equal to the start coordinates.
So, an octagonal pad should have 9 vertexes, but some version of Proteus only outputs 8 vertexes.
Gerber files are nothing else but just some human-readable plain text files. So let’s open the problematic file in a text editor:
G04 PROTEUS RS274X GERBER FILE* %FSLAX24Y24*% %MOIN*% ... %AMDIL007*4,1,8,-0.0300,0.0380,-0.0180,0.0500,0.0180,0.0500,0.0300,0.0380,0.0300,-0.0380,0.0180,-0.0500,-0.0180,-0.0500,-0.0300,-0.0380,0*% <1> %ADD17DIL007*% <2> ...
This long line defines the octagonal aperture macro, AM = Aperture Macro, DIL007 is the name of this macro.
This line defines an aperture D17 with DIL007.
To make the content easier to read, we can break the lines, like this:
%AMDIL007* 4,1,8, <1> -0.0300,0.0380, <2> -0.0180,0.0500, <3> 0.0180,0.0500, <4> 0.0300,0.0380, <5> 0.0300,-0.0380, <6> 0.0180,-0.0500, <7> -0.0180,-0.0500, <8> -0.0300,-0.0380, <9> 0*% <10>
4: Outline macro; 1: Exposure on; 8: The number of vertices of the outline = the number of coordinate pairs minus one. An integer ≥3.
Now, we are sure the aperture macro is wrong.
How to Fix
Just copy the coordinate of the first vertex (i.e. the line just after "4,1,8") and paste it before the "Rotation angle" line (i.e. the 0*% line):
|Please don’t copy the content here and paste it in your file, because your aperture may have different dimensions.|
%AMDIL007* 4,1,8, -0.0300,0.0380, <1> -0.0180,0.0500, 0.0180,0.0500, 0.0300,0.0380, 0.0300,-0.0380, 0.0180,-0.0500, -0.0180,-0.0500, -0.0300,-0.0380, -0.0300,0.0380, <2> 0*%
The 1st vertex.
The 9th vertex. 1st and 9th should be the same.
Now, correct all layers (for example, the top/bottom copper layers and the corresponding solder mask layers) which contain this type of aperture macro.
Before you place the order, it’s strongly recommended to check every layer in a Gerber viewer, Gerbv is recommended.