Electronic – Given only a gerber file how to automatically find out the number of pads that are there on the PCB

gerbvpcb

I am building a website right now , and am trying to automatically calculate the number of PCB pads that are there given only a gerber file. One way is to manually review this. Is there any other way to determine how many pads a gerber file has?
From a BOM one can easily find it. However, from the gerber is there anyway to find it?

Best Answer

A Gerber artwork is mostly rendered by three "D-code" commands. D01 means move with exposure on. D02 means move with exposure off. D03 means flash. Open a Gerber file with a text editor and you can see the D-code commands at the end of the lines with the coordinates in front.

Typically, almost all the pads should be flashes on the soldermask layers. So counting the flashes on the soldermask layers would give you an estimate. But I don't think there is a sure way of knowing what is a pad from the Gerber file alone.