Root/
| Source at commit d70dc71cfe3771ae1ca8c0e11b7e41b466b3c26e created 6 years 7 months ago. By Werner Almesberger, fab/drl2gerber: support metric drill files | |
|---|---|
| 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 | sub begin |
| 16 | { |
| 17 | return if $began; |
| 18 | $began = 1; |
| 19 | |
| 20 | print "G04 MACHINE-GENERATED FROM DRILL FILE*\n" || die; |
| 21 | print "G01*\n" || die; # linear Interpolation |
| 22 | print "G70*\n" || die; # inch units |
| 23 | print "G90*\n" || die; # absolute Mode |
| 24 | if ($mm) { |
| 25 | print "%MOMM*%*\n" || die; # millimeters, RS274X-style |
| 26 | } else { |
| 27 | print "%MOIN*%*\n" || die; # inches, RS274X-style |
| 28 | } |
| 29 | print "%FSLAX34Y34*%\n" || die; # format |
| 30 | } |
| 31 | |
| 32 | while (<>) { |
| 33 | chop; |
| 34 | if (/^METRIC/) { |
| 35 | $mm = 1; |
| 36 | next; |
| 37 | } |
| 38 | if (/^T(\d+)C/) { |
| 39 | &begin; |
| 40 | print "%ADD", $1 + 10, "C,$'*%\n" || die; |
| 41 | next; |
| 42 | } |
| 43 | if (/^T(\d+)$/) { |
| 44 | &begin; |
| 45 | print "G54D", $1 + 10, "*\n" || die; |
| 46 | next; |
| 47 | } |
| 48 | if (/^X([-0-9.]+)Y([-0-9.]+)$/) { |
| 49 | &begin; |
| 50 | printf("X%dY%dD03*\n", $1 * 10000, $2 * 10000) || die; |
| 51 | next; |
| 52 | } |
| 53 | if (/^X([-0-9.]+)Y([-0-9.]+)G85X([-0-9.]+)Y([-0-9.]+)$/) { |
| 54 | &begin; |
| 55 | printf("X%dY%dD02*\nX%dY%dD01*\n", |
| 56 | $1 * 10000, $2 * 10000, $3 * 10000, $4 * 10000) || die; |
| 57 | next; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | &begin; |
| 62 | print "M02*\n" || die; |
| 63 | |
Branches:
master
