Détail du package

whats-that-gerber

tracespace1.6kMIT4.2.7

Identify Gerber and drill files by filenamee

pcb, gerber, excellon, circuit

readme

what's that gerber?

latest next david

Identify Gerber and drill files by filename

Have you got a bunch of Gerber files lying around without any idea what they're for? We've all been there. whats-that-gerber is here to help.

Part of the tracespace collection of PCB visualization tools.

install

npm install --save whats-that-gerber
# or
yarn add whats-that-gerber

Or, use a script tag:

<script src="https://unpkg.com/whats-that-gerber@^4.0.0/dist/whats-that-gerber.min.js"></script>
<script>
  // global variable whatsThatGerber now available
  var parser = whatsThatGerber()
</script>

usage

Pass whatsThatGerber an array of filenames from a PCB, and it will give you back an object keyed by filename with the best guess it can make for the type and side of each file. If both side and type are null, the filename cannot be identified as a Gerber / drill file.

const whatsThatGerber = require('whats-that-gerber')

const filenames = ['my-board-F_Cu.gbr', 'my-board-B_Cu.gbr', 'foo.bar']
const typeByFilename = whatsThatGerber(filenames)
// {
//   'my-board-F_Cu.gbr': {type: 'copper', side: 'top'},
//   'my-board-B_Cu.gbr': {type: 'copper', side: 'bottom'},
//   'my-board-notes.gbr': {type: 'drawing', side: null},
//   'foo.bar': {type: null, side: null},
// }

layer types and names

There are 12 available layer types, were a type is an object of the format:

{
  side: 'top' | 'bottom' | 'inner' | 'all' | null,
  type: 'copper' | 'soldermask' | 'silkscreen' | 'solderpaste' | 'drill' | 'outline' | 'drawing' | null,
}

You can get an array of all types with:

const {getAllLayers} = require('whats-that-gerber')
const allLayers = getAllLayers()
side type
'top' 'copper'
'top' 'soldermask'
'top' 'silkscreen'
'top' 'solderpaste'
'bottom' 'copper'
'bottom' 'soldermask'
'bottom' 'silkscreen'
'bottom' 'solderpaste'
'inner' 'copper'
'all' 'outline'
'all' 'drill'
null 'drawing'

constants

Side and type constants are exported for your usage:

const {
  // layer types
  TYPE_COPPER, // 'copper'
  TYPE_SOLDERMASK, // 'soldermask'
  TYPE_SILKSCREEN, // 'silkscreen'
  TYPE_SOLDERPASTE, // 'solderpaste'
  TYPE_DRILL, // 'drill'
  TYPE_OUTLINE, // 'outline'
  TYPE_DRAWING, // 'drawing'

  // board sides
  SIDE_TOP, // 'top'
  SIDE_BOTTOM, // 'bottom'
  SIDE_INNER, // 'inner'
  SIDE_ALL, // 'all'
} = require('whats-that-gerber')

checking if a layer type is valid

You can check if any given string is a valid layer type with:

const {validate} = require('whats-that-gerber')

const type1 = {side: 'top', type: 'copper'}
const type2 = {side: 'foo', type: 'silkscreen'}
const type3 = {side: 'bottom', type: 'bar'}

console.log(validate(type1)) // {valid: true, side: 'top', type: 'copper'}
console.log(validate(type2)) // {valid: false, side: null, type: 'silkscreen'}
console.log(validate(type3)) // {valid: false, side: 'bottom', type: null}

supported cad programs

We should be able to identify files output by the following programs:

  • KiCad
  • Eagle
  • Altium
  • Orcad
  • gEDA PCB
  • DipTrace

contributing

Please read the Contributing Section of the main README for development setup instructions.

If you're adding or modifying a filetype matcher, please remember to add or modify an example filename in @tracespace/fixtures/gerber-filenames.json to ensure your change is tested.

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

4.2.7 (2022-03-12)

Note: Version bump only for package whats-that-gerber

4.2.2 (2020-10-13)

Note: Version bump only for package whats-that-gerber

4.2.0 (2019-10-10)

Bug Fixes

  • deps: Upgrade all dependencies (7f3c6f4)

4.1.1 (2019-06-05)

Bug Fixes

  • whats-that-gerber: Support for PCB:NG Eagle, .gbx, .art files (#268) (1449cba), closes #246 #248

4.0.2 (2019-03-24)

Bug Fixes

  • whats-that-gerber: Add Orcad matchers for .drd and .npt (#189) (2894208)

4.0.1 (2019-03-23)

Bug Fixes

  • whats-that-gerber: Recognize DipTrace inner copper layers (#171) (100a95b), closes #138

4.0.0 (2019-03-09)

Note: Version bump only for package whats-that-gerber

4.0.0-next.19 (2019-03-09)

Features

  • Add typescript definitions to all consumable modules (#103) (bb6e8f9)

4.0.0-next.15 (2018-11-13)

Features

  • whats-that-gerber: Use collection of filenames to determine type (#77) (6919549)

BREAKING CHANGES

  • whats-that-gerber: Output of whats-that-gerber changed from a single string to an object keyed by the filenames passed in as an array

4.0.0-next.13 (2018-09-12)

Features

  • whats-that-gerber: Add support for diptrace filenames (f3d5d9a)

4.0.0-next.12 (2018-07-17)

Features

  • whats-that-gerber: Add support for eagle 9+ filenames (#76) (3b8f570)

4.0.0-next.11 (2018-07-02)

Bug Fixes

  • whats-that-gerber: Improve Altium mech layer recognition (#70) (e48d03f), closes #69

4.0.0-next.10 (2018-06-27)

Features

  • whats-that-gerber: Match Altium internal planes as icu layer (#68) (f0155e2), closes #67

4.0.0-next.9 (2018-06-19)

Note: Version bump only for package whats-that-gerber

4.0.0-next.4 (2018-04-27)

Note: Version bump only for package whats-that-gerber

4.0.0-next.3 (2018-04-18)

Note: Version bump only for package whats-that-gerber