| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #!/bin/bash
- ifnsvg="../power-conn-pcb_5.svg"
- ifn="../power-conn-pcb_5.ps"
- s=100000
- s_inv=`echo "1.0/$s" | bc -l`
- f_ink=`echo "72/25.4" | bc -l `
- f_ink_inv=`echo "25.4/72" | bc -l `
- viewbox=`cat $ifnsvg | xpup '/svg/@viewBox'`
- x0=`echo "$viewbox" | cut -f1 -d' '`
- y0=`echo "$viewbox" | cut -f2 -d' '`
- x1=`echo "$viewbox" | cut -f3 -d' '`
- y1=`echo "$viewbox" | cut -f4 -d' '`
- pstoedit -f gnuplot $ifn raw.gp
- head -n -7 raw.gp > body.gp
- tail -n 7 raw.gp > outline.gp
- ## A better way?
- ## $ xj ../power-conn-pcb_5.svg | \
- ## jq '.["{http://www.w3.org/2000/svg}svg"]["{http://www.w3.org/2000/svg}g"][] | select( . >= {} ) | select( .["@{http://www.inkscape.org/namespaces/inkscape}label"] == "outline" )'
- R=0.3
- clipcli -t union -S nonzero -O 1 -s body.gp -F -x $s -T -R $R > raw_u.gp
- clipcli -t union -S nonzero -O 1 -s outline.gp -F -x $s -T -R $R >> raw_u.gp
- t=`echo "$f_ink_inv / $s" | bc -l`
- cat raw_u.gp | ./gpmat $t 0 0 $t > out.gp
- ###
- ./xj $ifnsvg | \
- jq -c '.["{http://www.w3.org/2000/svg}svg"]["{http://www.w3.org/2000/svg}g"]["{http://www.w3.org/2000/svg}circle"][] | [ .["@cx"], .["@cy"] ]' | \
- tr -d '[]' | sed 's/,/ /g' | \
- ./gpmat 1 0 0 -1 0 $y1 > drill.txt
- ###
- echo -e "G90\nG21\n\n" > out.ngc
- ./gp2ngc out.gp | \
- grecode -cw >> out.ngc
- minx=`./ngc_bounds out.ngc | grep min_x | cut -f2 -d' '`
- miny=`./ngc_bounds out.ngc | grep min_y | cut -f2 -d' '`
- echo "# $minx $miny"
- #shiftx="-50"
- #shifty="-40"
- shiftx="-85"
- shifty="-10"
- grecode -shift -$minx -$miny out.ngc | \
- grecode -shift $shiftx $shifty | \
- sed 's/^G0\(.*\)/G0 Z1\nG0\1\nG1 Z-1/' | \
- sed 's/^[gG]1\(.*\)/G1\1 Z-1/' > out_fin.ngc
- cat drill.txt | \
- awk '{ print "G0 Z1\nG0", "X"$1, "Y"$2, "Z1\nG1 Z-1\nG0 Z1\n" }' | \
- grecode -cw > drill.ngc
- grecode -shift -$minx -$miny drill.ngc | \
- grecode -shift $shiftx $shifty > drill_fin.ngc
- cat out_fin.ngc drill_fin.ngc > fin.ngc
|