File: PCB2HPGL

package info (click to toggle)
pcb 20140316-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 22,212 kB
  • ctags: 16,012
  • sloc: ansic: 123,955; sh: 7,306; yacc: 5,087; pascal: 4,118; makefile: 1,559; perl: 552; lex: 438; awk: 157; lisp: 86; tcl: 63; xml: 20
file content (147 lines) | stat: -rw-r--r-- 2,440 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/perl
#
#	
#	Der der Autor ist kein geringerer wie <smilebef@web.de> der Smilie
#	Also Fragen zu Hpgl oder Plotter,
#	mglicherweise kann ich ja helfen
#
#	Also ganz einfach die Layer.Dateien mit diesen Program erzeugen
#	mit "Program pcb-Datei"
#	das ganze in einem Verzeichnis wo ihr auch schreibrechte habt
#	und dann ganz einfach den gewnchten Layer auf den Plotter kopieren
#	zBsp. so "cat Layer.1.jenachdem.hpgl > /dev/lp0
#	den Stift mt ihr dem Plotter in die Hand geben
#	und den Stiftrevolver entnehmen da es eine Kollision giebt.

if( $ARGV[0] )
{
}
else{print "use ".$0." [pcb-file] to convert to hpgl\n";
exit;};

sub abschnitt

{
close(DATEI);
if(/Layer.(\d)\s.(\w+)../)
{
$da="Layer.$1.$2.hpgl";
}
open(DATEI , ">$da");
}



sub via

{

open(DATE,">>Layer.Via.hpgl");
if(/Via.(\S+)\s(\S+)\s(\S+)\s(\S+)/)
{
print(DATE "PA".($1).",".($2).";CI".($4).";");
}
close(DATE);
}
sub pin

{
open(DATE,">>Layer.Pin.hpgl");
if(/\tPin.(\S+)\s(\S+)\s(\S+)\s(\S+)/)
{
print(DATE "PA".($1).",".($2).";CI".($4).";");
}
close(DATE);

}



sub text

{
open(DATE,">>Layer.Text.hpgl");
if(/\tText.(\S+)\s(\S+)\s(\S+)\s(\S+)\s"(\S+)"/)
{
if($3==0){$di=";DI0,1;";};
if($3==1){$di=";DI1,0;";};
print(DATE "PA".$1.",".$2.$di."SI".($4/450).",".($4/675).";LB".$5."\e;");
}
close(DATE);

}



sub linie

{
if(/\tLine.(\S+)\s(\S+)\s(\S+)\s(\S+)/)
{
print (DATEI "PU".($1).",".($2).";PD".($3).",".($4).";PU;");
}
}



sub arc

{
if(/\tArc.(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)/)
{
if($6==90){$sin=1;$cos=0;}
if($6==-90){$sin=-1;$cos=0;}
if($6==0){$sin=0;$cos=1;}
if($6==180){$sin=0;$cos=-1;}
if($6==-180){$sin=0;$cos=-1;}
if($6==270){$sin=-1;$cos=0;}
if($6==-270){$sin=1;$cos=0;}
print (DATEI "PA".($1-($3*$cos)).",".($2+($3*$sin)).";PD;AA".($1).",".($2).",".($7*(-1)).";PU;");
}
}



sub polygon

{
if(/\t\t.(\S+)\s(\S+).\s.(\S+)\s(\S+).\s.(\S+)\s(\S+).\s.(\S+)\s(\S)./)
{
print (DATEI "PA".$1.",".$2.";RA".$5.",".$6.";");
}
}

# ist noch nicht eingebunden.
#sub polygon

#{
#s/\t\t./PU/;
#s/\s/,/;
#while(/\)\s\(/)
#{s/\)\s\(/\;PD/;}
#while(/\S\s\S/)
#{s/\s/,/;}
#s/\)/\;PU\;/;
#print (DATEI $_);
#}


open(DATE,">Layer.Via.hpgl");
close(DATE);
open(DATE,">Layer.Text.hpgl");
print(DATE "DT\e;");
close(DATE);
open(DATE,">Layer.Pin.hpgl");
close(DATE);
while(<>)
{
if(/\tPin/){&pin}
if(/Layer/){&abschnitt;}
if(/Via/){&via;}
if(/\tArc/){&arc;}
if(/\tLine/){ &linie;}
if(/\t\t/){&polygon;}
if(/\tText\(/){&text;}
}
close(DATEI);