← 博客

什么是 Gerber 文件?— RS-274X、Excellon 和 X2 全解析

What is a Gerber file — MakerSuite 3D

板厂都在用的那套交付格式

只要你打过样,就压缩过一个装满 .gtl、.gbl、.gto、.drl 这些奇怪后缀的文件夹,发给板厂。那就是 Gerber 文件。它是 PCB 设计工具(KiCad、Altium、Eagle、EasyEDA)和制造设备(光绘机、钻孔机、贴片头)之间的通用语言——没有 Gerber,就没有板。这篇讲清楚这个 40 多年没被淘汰的格式里到底装了什么。

Gerber 文件里到底是什么

每个 Gerber 文件都是一段纯文本的 2D 绘图指令流(RS-274X 格式),描述 PCB 的某一层——顶层铜、底层铜、顶层丝印、阻焊等等。可以把它想成制造业版本的矢量 PDF:光圈定义(D 码)说明要盖什么形状的印章(圆形焊盘?方形?矩形?),坐标指令(G/M 码)说明盖在哪。用记事本打开会看到 G01X1000Y2000D01 这种行——意思是从当前位置画一条线到 (1,2) mm。就这么简单。整个文件就是一堆盖章和走线的列表。

这个格式保证了什么

  • 每层一个文件顶层铜、底层铜、每个内层铜、顶/底丝印、顶/底阻焊、板框。两层板一般 8~10 个文件,12 层 HDI 可以超过 20 个。
  • 钻孔走 Excellon专门存钻孔坐标和钻头尺寸的独立纯文本格式(严格来说不算 Gerber)。金属化孔和非金属化孔通常分成两个文件。
  • RS-274X 和 X2 的区别RS-274X(1998)是所有板厂都认的基础版。Gerber X2(2014)是超集,把层功能、网络名、元件数据也塞了进去,CAM 工具可以自动做 DFM。现在的 KiCad 和 Altium 默认导出 X2。
  • 纯文本、不绑厂商任何编辑器都能打开,任何 CAM 工具都能读。没有专有二进制格式、没有厂商锁定、不用交授权费。
  • 公制英制都行通过 %MO 指令切换。欧美板厂一般用英制(mil),亚洲板厂两种都收。单位搞混是缩放出错的头号原因。
  • 贴片(CPL)是另一个文件元件的 X/Y、旋转角、位号在跟 Gerber 一起交付的 centroid 文件里,不在 Gerber 本身里面。找代工贴片的话两个都得给。

怎么处理 Gerber

  1. Open pcbviewer.app — 把 Gerber 压缩包(不用解压)直接拖进查看器。
  2. 检查层叠顺序 — 顶层铜、丝印、阻焊应该清晰可见。如果哪一层翻了面或者镜像了,说明导出设置有问题。
  3. 确认钻孔正好落在焊盘上 — 偏移的钻孔寄回来就是穿过走线的废孔。3D 视图下这种错误一眼就能看出来。
  4. 检查板框闭合 — 没闭合的板框多边形会让板厂自己猜边界,通常直接退回成矩形。
  5. 打包成 zip 发出去 — 大多数板厂接受装了全部层 + Excellon 钻孔文件的压缩包。复杂板的话附一个 README,写清层叠结构和网络数。

Drop a Gerber zip — see your PCB in 3D before you ship it to the fab.

免费试用 MakerSuite 3D

为什么 40 年过去 Gerber 还是赢家

Gerber 是纯文本、不绑厂商、人眼能读的,全世界每家板厂都支持。想取代它的 IPC-2581、ODB++ 元数据虽然更全,但要么要授权工具,要么要厂商买单,所以一直没出圈。反观 RS-274X 导出,每个 EDA 工具里都是一个勾选框——今天导出的文件,20 年后的 CAM 工位也能打开。无聊得让人放心,这正是 Gerber 赢的原因。

什么时候会用到 Gerber

  • 去 JLCPCB、PCBWay、OSH Park 打样 — 每家都要上传 Gerber 压缩包
  • 量产前的 DFM 审查 — CAM 工程师把你的 Gerber 过一遍 DRC,找出公差问题
  • 钢网制造 — 激光切割 SMD 钢网靠的就是锡膏层的 Gerber
  • 归档没源文件的老设计 — 拿 Gerber 用任何 EDA 工具都能反推出大致的板图
  • 验收第三方做的板 — 就算拿不到源工程,也能加载他们的 Gerber,付款给板厂前先过一遍

为什么 Gerber 要用浏览器查看器看

你的 Gerber 压缩包装的是整块板的 IP——每条走线、每个元件位置、每个网络名。发布前或者 NDA 项目传到云端查看器,就是给自己挖坑。MakerSuite 3D 用纯 JavaScript 在浏览器里直接解析 RS-274X 和 Excellon——不走服务器、不上传、不排队。你拖进来的文件从头到尾没离开这个标签页。和板厂内部用的是同一套解析逻辑,只是挪到客户端跑而已。

常见问题

What exactly is inside a Gerber file?

Each Gerber file is a plain-text stream of 2D drawing commands (RS-274X format) describing a single PCB layer — the top copper, bottom copper, top silkscreen, solder mask, etc. Think of it as the manufacturing equivalent of a vector PDF: aperture definitions (D-codes) say what shapes to stamp, and coordinate commands say where to stamp them. A complete board is a folder of these files, usually zipped together with an Excellon drill file.

How many Gerber files does one PCB need?

A typical 2-layer board ships with 8–10 files: top and bottom copper, top and bottom solder mask, top and bottom silkscreen, board outline, and one or two Excellon drill files (plated and non-plated holes). A 4-layer board adds the inner copper layers. A complex 12-layer HDI board can push past 20 files.

What's the difference between Gerber X2 and RS-274X?

RS-274X (from 1998) is the baseline format that every manufacturer reads. Gerber X2 (2014) is a superset that embeds metadata — layer function, net names, component attributes — so CAM tools can do automatic panelization and DFM. Our viewer reads both, and modern KiCad/Altium default to X2. If your fabricator complains, export as plain RS-274X.

Can I view Gerber files without installing KiCad or Altium?

Yes — drop your Gerber zip onto MakerSuite 3D. The parser runs in your browser, renders all layers with aperture shapes, composites the board in 3D, and shows drill hits and board outline together. No CAM software, no login, no upload. The same RS-274X parser is what fabricators use internally, just ported to JavaScript.

Are Gerber files editable?

Technically yes (they're plain text), but practically no — hand-editing aperture tables and coordinate streams is how you ship a $10k fab mistake. If you need to change the board, edit the source (KiCad, Altium, EasyEDA) and re-export. Gerber is an output-only handoff format, not a working file.

相关文章

How to Open Gerber FilesGerber Viewer OnlineFree Online PCB 3D Viewer

把 Gerber 压缩包拖进来 — 每一层都 3D 可视化

打开 Gerber 查看器