Skip to content

Commit

Permalink
Added support for excellon drill files w/ leading/trailing set in M71…
Browse files Browse the repository at this point in the history
…/M72 line
  • Loading branch information
davidworkman9 committed Dec 19, 2018
1 parent 2adf8ca commit 41d3e69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/gerber-parser/lib/_parse-drill.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var parseCoord = require('./parse-coord')
var RE_ALTIUM_HINT = /;FILE_FORMAT=(\d):(\d)/
var RE_KI_HINT = /;FORMAT={(.):(.)\/ (absolute|.+)? \/ (metric|inch) \/.+(trailing|leading|decimal|keep)/

var RE_UNITS = /(INCH|METRIC)(?:,([TL])Z)?/
var RE_UNITS = /(INCH|METRIC|M71|M72)(?:,([TL])Z)?/
var RE_TOOL_DEF = /T0*(\d+)[\S]*C([\d.]+)/
var RE_TOOL_SET = /T0*(\d+)(?![\S]*C)/
var RE_COORD = /((?:[XYIJA][+-]?[\d.]+){1,4})(?:G85((?:[XY][+-]?[\d.]+){1,2}))?/
Expand Down Expand Up @@ -87,7 +87,7 @@ var parseUnits = function(parser, block, line) {
var units = unitsMatch[1]
var suppression = unitsMatch[2]

if (units === 'METRIC') {
if (units === 'METRIC' || units === 'M71') {
setUnits(parser, 'mm', line)
} else {
setUnits(parser, 'in', line)
Expand Down
4 changes: 4 additions & 0 deletions packages/gerber-parser/test/gerber-parser_drill_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,17 @@ describe('gerber parser with gerber files', function() {
{type: 'set', line: 2, prop: 'units', value: 'mm'},
{type: 'set', line: 3, prop: 'units', value: 'in'},
{type: 'set', line: 4, prop: 'units', value: 'mm'},
{type: 'set', line: 5, prop: 'units', value: 'in'},
{type: 'set', line: 6, prop: 'units', value: 'mm'},
]

expectResults(expected, done)
p.write('INCH\n')
p.write('METRIC\n')
p.write('INCH,TZ\n')
p.write('METRIC,LZ\n')
p.write('M72,LZ\n')
p.write('M71,LZ\n')
p.end()
})

Expand Down

0 comments on commit 41d3e69

Please sign in to comment.