SolvedLibrePCB Gerber Generation : Octagons were not correctly handled by manufacturers

VERSION / OS / ENVIRONMENT
LibrePCB Version: 0.1.5
Git Revision:     a435c5095c6f94df4da130fe832ea97f42d17901
Build Date:       2020-10-03T19:48:36
Linking type:     static
Unbundled libs:   -
Qt Version:       5.14.2 (built against 5.14.2)
CPU Architecture: x86_64
Operating System: Ubuntu 20.10
Platform Plugin:  xcb
SUMMARY

Even if files seems to be correctly formatted (Ucamco reference gerber viewer says ๐Ÿ‘ ),
2 big manufacturers (PCBWay or JLCPCB) have difficulties to handle Gerber files generated by LibrePCB.
It seems that octagons are not correctly handled.
It is with octagons with difference between width and height.
Others seems to be correctly handled.

STEPS TO REPRODUCE
  1. create a component with top octagonal pad of 1.0 x 0.6 mm
  2. insert it in your design
  3. generate Gerber files
  4. test it in Ucamco reference Gerber viewer => it's ok
  5. send them to a manufacturer (here : PCBWay or JLCPCB) => files refused
EXPECTED RESULTS

image

ACTUAL RESULTS

image

EQ

ADDITIONAL INFORMATION
17 Answers

โœ”๏ธAccepted Answer

Urban and me figured out that the hardcoded octagon Aperture Macro works in a CAM tool (we call it CAM tool A in this post), this makes me belive this bug can be found, another reason I believe it can be fixed is Gerber's Aperture Macro Primitive outline (code 4 in the specification) is a simple one, and it is widely used in Gerber files for various PCB design softwares.

Because the CAM tools used are aged and Gerber spec is always keeping evolving. So one idea is to have a look at the the outline definition in the old Gerber specification as the CAM developers must read the spec when they developed it. I googled and download a copy of version from 2001 (Part Number 414 100 014 Rev D March, 2001, 61 pages in total), there's no big differences between the old one and the pretty new one (Revision 2021.02, 203 pages in total).

In the old spec, on page 20, section "AM parameter syntax rules", it writes:

Do not begin a variable primitive modifier with a minus sign (for example,
-$1). To indicate negative, precede the variable with 0 (for example, 0-$1).

With the information above, I modified the macro definition, use 0-$1 format, it didn't work.

While in the lates spec, on page 68, it has a section "4.5.4 Macro Variables and Expressions" which is informative and gives lots of examples which is quite good for intuitive learning especially for a person who is not very familiar with Gerber format.

If the hardcoded version works, one natural debugging idea is: Maybe we can try to use the mixed version, i.e. some parameters are hardcoded, but for some of them we use variables. We replace the hardcoded value one by one, see when the macro will trigger the bug of the CAM tool (The only thing we need is just some elbow grease and be patient enough)

The test file is based on the Gerber from @dbrgn.

%FSLAX66Y66*%
%MOMM*%
G01*
G74*
%AMROTATEDOCTAGON*4,1,8,-$1/2,$2/2-$3,-0.869239,0.65,0.869239,0.65,$1/2,0.269239,1.25,-0.269239,0.869239,-0.65,-0.869239,-0.65,-1.25,-0.269239,-1.25,0.269239,$4*%
%ADD10ROTATEDOCTAGON,2.5X1.3X0.380761X0.0*%
D10*
X5606051Y5606051D03*
M02*

With the above macro, we can get this image in CAM tool A:

divide

Now if we change $2/2-$3 to 0.65-$3 ($2/2 is 0.65), we get:

minus

This is the shape we expected! How?!

Then I use 0.5x$2-$3 and $2x0.5-$3, it didn't helped.

Every corner is OK except the spike at top left, the coordinate of that point must come from the calculation of $2/2-$3, $2 is 1.3, $3 is 0.380761, so I measured the distance between the center of the macro and the spike, the value is around 0.8mm. How can we get 0.8 from $2/2-$3? After several times of attempts I see 1.3/(2-0.380761) = 0.80, is this a coincidence? Maybe.

When I googled the keyword "gerber macro arithmetic operator" I found the following thread and was inspired.

[Gerbv-devel] [ gerbv-Bugs-3172530 ] Operator precedence not implemented in aperture macros

It's not hard to verify this guess: just change the value of $2 then measure the coordicate of the spike again, if the distance is the same with the value from $2/(2-$3), then the guess is correct. If $2 = 2, the calculated value is about 1.23. Modify the Gerber accordingly and open it in CAM tool A.

verify

Yes, it is 1.23!

The bug is clear, let's compose another version for this macro, read the Gerber spec and checked an example macro from KiCad, I get this one (It is a complete Gerber layer, can be saved as a filename.gbr file to test):

%FSLAX66Y66*%
%MOMM*%
G01*
G74*

%AMROTATEDOCTAGON*
0 Oblong octagon, 8 corners, with rotation*
0 The origin of the aperture is its center*
0 number of corners: always 8*
0 $1: Length*
0 $2: Width*
0 $3: Chamfer*
0 $4 Rotation angle, in degrees counterclockwise*
0 create outline with 8 corners*
$5=$1/2*
$6=$2/2*
4,1,8,
0-$5,$6-$3,
$3-$5,$6,
$5-$3,$6,
$5,$6-$3,
$5,$3-$6,
$5-$3,0-$6,
$3-$5,0-$6,
0-$5,$3-$6,
0-$5,$6-$3,
$4*
%

%ADD10ROTATEDOCTAGON,2.5X1.3X0.380761X0.0*%
D10*
X0Y0D03*
M02*

It works correctly in:

oct-macro-in-ucamco-reader

So I think for compatiblity reason, LibrePCB can consider to modify the this aperture macro definition (note that my version is just a quick and dirty fix). This is not a problem of LibrePCB, it's just the crappy CAM tools caused these issues.

Interestingly, the version works in many Gerber readers does not work in JLCPCB.com's previewer! I've told the relevant developer at JLCPCB to check if it's a bug in their code.

Personally I had fun during this debugging process, I want to thank this bug and all you guys :)

Other Answers:

I checked how KiCad 5 and Eagle 7 export such pads. Actually I guess they don't even support octagon pads where width!=height (really?!) so I checked it with rotated oblongs and rotated regular octagons. The result quite surprises me. Kicad uses G36/G37 regions (which is not recommended by the Gerber specs) and Eagle even draws a lot of strokes to fill a pad ๐Ÿ˜‚

image

Related Issues:

4
LibrePCB Gerber Generation : Octagons were not correctly handled by manufacturers
Urban and me figured out that the hardcoded octagon Aperture Macro works in a CAM tool (we call it C...
3
visidata AttributeError: '_curses.curses window' object has no attribute 'get_wch'
@qrkourier I just followed pyenv/pyenv#240 (comment): with a few changes Now it works. ...
3831
axios Axios catch error returns javascript error not server response
I have exactly the same environment Try this: Modify from console.log(error) to console.log(error.re...
731
scrapy ' error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 '
@euler16 for scrapy with Python 3 you'll need with Python 2 you'll need I wanted to install scrapy i...
684
laradock Mysql. The server requested authentication method unknown to the client [caching_sha2_password]
alter user 'username'@'localhost' identified with mysql_native_password by 'password'; would fix it....
517
react navigation screenIsActive prop / componentDidFocus event for TabNavigator items
It probably makes sense to add lifecycle hooks to screens In one of my Tabs i need to load Data from...
474
meteor [1.4.2.1] Error: ENFILE: file table overflow
I was getting the same after an upgrade to macOS Sierra Turns out macOS have a harsh limit on number...
423
ipython Last jedi release (0.18.0) is incompatible with ipython (7.19 and 7.18 tested); reason - column arg was deprecated, and now removed
As a temporary fix for anyone just trying to get things working again: It would be really nice if yo...
397
material ui Module not found: Can't resolve 'material-ui-icons/Menu' Martial Next
For anyone else experiencing this issue: npm install @material-ui/icons https://www.npmjs.com/packag...
395
laravel dompdf (1/1) ErrorException Non-static method Barryvdh\DomPDF\PDF::loadView() should not be called statically
This happens because you are namespacing the wrong PDF class You are namespacing Barryvdh\DomPDF\PDF...
378
webpacker localIdentName option moved in css-loader configuration
I faced same issue after upading css-loader but I solved it If you check css-loader readme ...
364
react navigation Send data back from child screen?
@itswaze You can do something along these lines to pass back from the child screen ...
358
react navigation How to goBack from nested StackNavigator?
@dhruvparmar372 According to the NOTE in the doc a navigator's navigation prop may not have the help...
352
axios POST request works in Browser but not on Node
This might be considered a duplicate of #789 I was able to use the form-data package with Axios in n...
317
react navigation Best pattern for a 'Save' button in the header
Try setting your component instance's handleSave function as a navigation state parameter after the ...
310
DefinitelyTyped [@types/react] RefObject.current should no longer be readonly
It's not It'a intentionally left readonly to ensure correct usage even if it's not frozen ...
306
react native navigation [V3][Android] FATAL EXCEPTION: create_react_context
OK after a good night of sleep I've found why I was having this issue In the MainApplication.java I ...
303
ts node Custom typings not working with ts-node 8.0.2
When using with ts-node you have to add --files flag After updating to ts-node version 8.0.2 the cus...
294
ohmyzsh compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew
Per #9602 (comment) brew cleanup fixed it for me I am using Apple M1 When I added this line: export ...
292
laradock SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
+1 I'm having the same problem here. Info: Docker version ($ docker --version): Docker version 17.12...
289
vagrant vagrant box update - Fails with 404 Not Found error
A workarround to add in your Vagrantfile: Vagrant version Host operating system Ubuntu 16.04.3 LTS G...
263
vagrant vagrant --help displays a rubygems error
To fix this error: Vagrant version Host operating system Expected behavior vagrant and vagrant --hel...
262
date fns Can't resolve 'date-fns/_lib/format/longFormatters'
You probably forgot to install date-fns or Code: import DateFnsUtils from '@date-io/date-fns'; ...
259
virtualenv Error creating virtualenv with python3.6
The original poster's problem is due to not having the 'python3.6-venv' package installed ...
252
provider A Product was used after being disposed. flutter: Once you have called dispose() on a Product, it can no longer be used.
Oh I see what you're doing Don't: DO: i have a ChangeNotifireProvider that such that i do pushReplac...
248
react navigation Reset to nested route, "There is no route defined for..."
A quick workaround (not heavily tested): set the key property to null on your action. ...
238
axios Adding headers to axios.post method
Edit: I had to add Authorization to allowed headers in my CORS filter @jffernandez I'm having the sa...
231
axios Adding Retry Parameter
@mericsson I am too in need of exponential backoff when retrying I've put together the following whi...
224
homebrew openjdk Cask adoptopenjdk8 exists in multiple taps
I think AdoptOpenJDK8 should be removed from the homebrew-cask-versions repo Somone(TM) should proba...
222
nativescript cli TNS doctor doesn't recognize Xcode (High Sierra)
HI @philipfeldmann Can yhou please run xcodebuild -version and paste the output? May be Xcode is ins...
215
axios BaseURL not being used
Please IGNORE THIS ISSUE Found the problem: I was setting baseUrl but it should be baseURL. ...
205
axios How to ignore SSL issues
You can configure axios to use a custom agent and set rejectUnauthorized to false for that agent: Ho...
202
ipython NameError: name 'sys' is not defined
Ok that was easy The Jedi release on 12/25 version 0.18.0 is breaking tab completion pip install --u...
190
axios How to send Raw http for Instagram Authentication?
Yes StringClient uses the application/x-www-form-urlencoded format by default while axios uses appli...
186
vuetify [Bug Report] Could not find a declaration file for module 'vuetify/lib'
@KaelWD Thank you for the link More specifically this comment helped me out to properly update my ts...
182
axios CORS error No 'Access-Control-Allow-Origin' header is present on the requested resource
My solution is axios.get('https://cors-anywhere.herokuapp.com/' + yourUrl) update: doesn't work ...
181
runtime An assembly specified in the application dependencies manifest (RhWeb.deps.json) was not found
I also hit this For me it had to do with the use of in my .csproj when running in an environment tha...
179
react navigation Drawer changes in #1803 causes undocumented breaking changes to drawernavigators
Adding to the drawer configs fixed the issue for me. Current Behavior create a single drawer navigat...
178
laradock MySQL Container fails to start
I had the same issue last night I think it's the mysql version problem What I did was edited laradoc...
177
webpacker Compilation Failed without error message
In case anyone else runs into this I had to set webpack_compile_output: true in webpacker.yml for ra...
175
matplotlib 'NSWindow drag regions should only be invalidated on the Main Thread!' - macos/python
If you are running a webserver and using it to save Matplotlib make sure to set the backend to a non...
174
axios request progress?
@slim12kg Depending on the way you coded your project it may change if my code confuses you ...
174
ruby build Cannot install Ruby versions < 2.4 because of openssl@1.1 dependency
@jyr There are multiple things wrong with what you are doing First of all you are using rvm ...
169
NativeBase Needs to tap twice to fire onPress function when keyboard is open
@bm-software Use keyboardShouldPersistTaps={'handled'} and will works fine. react-native ...
167
react navigation Android header is overlapped
Yes @rockingskier I had a chat with the Expo guys Looks like we need to explicitly add padding for A...
165
DefinitelyTyped node_modules/@types/react-native/globals.d.ts (36,15): Duplicate identifier 'FormData'.
Fixed by set compilerOptions.types manually If you know how to fix the issue make a pull request ins...
163
ts node ts-node fails when ES Modules are in the dependency graph in Node.js 13+
It seems that ts-node fails to run with module: esnext in the tsconfig.json and type: module in the ...
161
typeorm Error: RepositoryNotFoundError: No repository for [Enitity] was found. Looks like this entity is not registered in current "default" connection?
https://typeorm.io/#/connection-options/common-connection-options Issue type: [x] question [x] bug r...
159
axios Missing documentation for downloading binary files
In case other stumple upon this thread when looking for an answer to serve external images from node...