Root/fab/drl2gerber

1#!/usr/bin/perl
2#
3# drl2gerber - Convert a KiCAD-generated Excellon drill file to Gerber
4#
5# Written 2011 by Werner Almesberger
6# Copyright 2011 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
15print "G04 MACHINE-GENERATED FROM DRILL FILE*\n" || die;
16print "G01*\n" || die; # linear Interpolation
17print "G70*\n" || die; # inch units
18print "G90*\n" || die; # absolute Mode
19print "%MOIN*%*\n" || die; # inches, RS274X-style
20print "%FSLAX34Y34*%\n" || die; # format
21
22while (<>) {
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
43print "M02*\n" || die;
44

Archive Download this file

Branches:
master



interactive