# Variables: # header # type : 0=gerber 1=drill # layer BEGIN{ st = 0; FS=",*"; } function ap_conv(ap_mm){ if (ap_mm < 1.0) return((ap_mm - 0.1) / 0.05); else return((ap_mm - 1.0) / 0.1 + 18); } function show_head() { print "[Version]"; print "PCBE:Version 0.54.1"; print "[BoardSize]"; print "X:300"; print "Y:210"; print "GRID:1,1"; print "ORIGIN:X=0.000,Y=0.000"; print "[LayerDef]"; print "1:NAME=SolPat,COLOR=1,DISP=ON,ACTIV=ON,PRINT=OFF"; print "2:NAME=CmpPat,COLOR=2,DISP=ON,ACTIV=ON,PRINT=OFF"; print "3:NAME=SolSil,COLOR=3,DISP=ON,ACTIV=ON,PRINT=OFF"; print "4:NAME=CmpSil,COLOR=4,DISP=ON,ACTIV=ON,PRINT=OFF"; print "5:NAME=SolRes,COLOR=5,DISP=ON,ACTIV=ON,PRINT=OFF"; print "6:NAME=CmpRes,COLOR=6,DISP=ON,ACTIV=ON,PRINT=OFF"; print "7:NAME=Outline,COLOR=0,DISP=ON,ACTIV=ON,PRINT=OFF"; print "8:NAME=Hole,COLOR=0,DISP=ON,ACTIV=ON,PRINT=OFF"; print "[DrawItems]"; } { if (type == 0){ if (st == 0 && substr($0, 1, 3) == "%AD") st = 1; else if (st == 1 && substr($0, 1, 1) == "D") st = 2; if (st == 1){ Dcode = substr($0, 4, 3); ap_mm = substr($2, 1, 6) * 25.4; #%ADD10R,0.0137X0.0550*% #%ADD18R,0.0984X0.0787*% #%ADD20R,0.1220X0.0197*% #RECT:X=14,Y=45,DX=4,DY=3,ANG=90,LE=0,AP=0 <---> 3x4/0deg if (substr($2, 7, 1) == "X") ap2_mm = substr($2, 8, 6) * 25.4; else ap2_mm = 0; # print Dcode, $2, ap_mm, ap2_mm; ap[Dcode] = int(ap_conv(ap_mm)+0.5); apm[Dcode] = ap_mm; if (ap2_mm == 0){ apm2[Dcode] = -1; ap2[Dcode] = -1;} else{ apm2[Dcode] = ap2_mm; ap2[Dcode] = int(ap_conv(ap2_mm)+0.5);} } if (st == 2){ if (header == 1) show_head(); st = 3; } if (st == 3){ if (substr($0, 1, 1) == "D"){ Dcode = substr($0, 1, 3); } if (substr($0,1,1) == "X"){ x = substr($0, 2, 6)/10000*25.4; y = substr($0, 9, 6)/10000*25.4; op = substr($0, 16, 2); if (op == "02"){ xs = x; ys = y; } else if (op == "01"){ printf("LINE:XS=%.3f,YS=%.3f,XE=%.3f,YE=%.3f,LE=%d,AP=%d\n", xs, ys, x, y, layer, ap[Dcode]); xs = x; ys = y; } else if (op == "03"){ xs = x; ys = y; if (ap2[Dcode] == -1) printf("LAND:X=%.3f,Y=%.3f,LE=%d,AP=%d\n", x, y, layer, ap[Dcode]); else{ # printf("RECT:X=%.3f,Y=%.3f,DX=%.3f,DY=%.3f,ANG=0,LE=%d,AP=%d\n", x, y, apm[Dcode], apm2[Dcode], layer, 0); if (apm[Dcode] < apm2[Dcode]){ L = apm2[Dcode]; S = apm[Dcode]; apsq = ap[Dcode]; for (i = y-L/2+S/2; i <= y+L/2-S/2; i+=S/2) printf("LAND:X=%.3f,Y=%.3f,LE=%d,SQ=%d\n", x, i, layer, apsq); } else{ L = apm[Dcode]; S = apm2[Dcode]; apsq = ap2[Dcode]; for (i = x-L/2+S/2; i <= x+L/2-S/2; i+=S/2) printf("LAND:X=%.3f,Y=%.3f,LE=%d,SQ=%d\n", i, y, layer, apsq); } } } } } } else if (type == 1){ if (st == 0 && substr($0, 1, 1) == "T") st = 1; else if (st == 1 && substr($0, 1, 1) == "%") st = 2; if (st == 1){ Tcode = substr($0, 1, 3); ap_mm = substr($0, 5, 5) * 25.4; ap[Tcode] = int(ap_conv(ap_mm)+0.5); } if (st == 2){ if (header == 1) show_head(); st = 3; } if (st == 3){ if (substr($0, 1, 1) == "T"){ Tcode = substr($0, 1, 3); } if (substr($0,1,1) == "X"){ if (substr($0, 7, 1) == "Y"){ x = substr($0, 2, 5)/10000*25.4; y = substr($0, 8, 5)/10000*25.4; } else{ x = substr($0, 2, 4)/10000*25.4; y = substr($0, 7, 5)/10000*25.4; } printf("LAND:X=%.3f,Y=%.3f,LE=%d,AP=%d\n", x, y, layer, ap[Tcode]); } } } }