Root/
| Source at commit c5c1b18b5aca501dc97bf787742983b4045ce620 created 6 years 7 months ago. By Werner Almesberger, fab/drl2gerber: put whitespace around operators | |
|---|---|
| 1 | #!/usr/bin/perl |
| 2 | # |
| 3 | # drl2gerber - Convert a KiCAD-generated Excellon drill file to Gerber |
| 4 | # |
| 5 | # Written 2011, 2017 by Werner Almesberger |
| 6 | # Copyright 2011, 2017 Werner Almesberger |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as published by |
| 10 | # the Free Software Foundation; either version 2 of the License, or |
| 11 | # (at your option) any later version. |
| 12 | # |
| 13 | |
| 14 | |
| 15 | print "G04 MACHINE-GENERATED FROM DRILL FILE*\n" || die; |
| 16 | print "G01*\n" || die; # linear Interpolation |
| 17 | print "G70*\n" || die; # inch units |
| 18 | print "G90*\n" || die; # absolute Mode |
| 19 | print "%MOIN*%*\n" || die; # inches, RS274X-style |
| 20 | print "%FSLAX34Y34*%\n" || die; # format |
| 21 | |
| 22 | while (<>) { |
| 23 | chop; |
| 24 | if (/^T(\d+)C/) { |
| 25 | print "%ADD", $1 + 10, "C,$'*%\n" || die; |
| 26 | next; |
| 27 | } |
| 28 | if (/^T(\d+)$/) { |
| 29 | print "G54D", $1 + 10, "*\n" || die; |
| 30 | next; |
| 31 | } |
| 32 | if (/^X([-0-9.]+)Y([-0-9.]+)$/) { |
| 33 | printf("X%dY%dD03*\n", $1 * 10000, $2 * 10000) || die; |
| 34 | next; |
| 35 | } |
| 36 | if (/^X([-0-9.]+)Y([-0-9.]+)G85X([-0-9.]+)Y([-0-9.]+)$/) { |
| 37 | printf("X%dY%dD02*\nX%dY%dD01*\n", |
| 38 | $1 * 10000, $2 * 10000, $3 * 10000, $4 * 10000) || die; |
| 39 | next; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | print "M02*\n" || die; |
| 44 | |
Branches:
master
