export 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. ifnsvg="../power-conn-pcb_5.svg"
  3. ifn="../power-conn-pcb_5.ps"
  4. s=100000
  5. s_inv=`echo "1.0/$s" | bc -l`
  6. f_ink=`echo "72/25.4" | bc -l `
  7. f_ink_inv=`echo "25.4/72" | bc -l `
  8. viewbox=`cat $ifnsvg | xpup '/svg/@viewBox'`
  9. x0=`echo "$viewbox" | cut -f1 -d' '`
  10. y0=`echo "$viewbox" | cut -f2 -d' '`
  11. x1=`echo "$viewbox" | cut -f3 -d' '`
  12. y1=`echo "$viewbox" | cut -f4 -d' '`
  13. pstoedit -f gnuplot $ifn raw.gp
  14. head -n -7 raw.gp > body.gp
  15. tail -n 7 raw.gp > outline.gp
  16. ## A better way?
  17. ## $ xj ../power-conn-pcb_5.svg | \
  18. ## 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" )'
  19. R=0.3
  20. clipcli -t union -S nonzero -O 1 -s body.gp -F -x $s -T -R $R > raw_u.gp
  21. clipcli -t union -S nonzero -O 1 -s outline.gp -F -x $s -T -R $R >> raw_u.gp
  22. t=`echo "$f_ink_inv / $s" | bc -l`
  23. cat raw_u.gp | ./gpmat $t 0 0 $t > out.gp
  24. ###
  25. ./xj $ifnsvg | \
  26. 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"] ]' | \
  27. tr -d '[]' | sed 's/,/ /g' | \
  28. ./gpmat 1 0 0 -1 0 $y1 > drill.txt
  29. ###
  30. echo -e "G90\nG21\n\n" > out.ngc
  31. ./gp2ngc out.gp | \
  32. grecode -cw >> out.ngc
  33. minx=`./ngc_bounds out.ngc | grep min_x | cut -f2 -d' '`
  34. miny=`./ngc_bounds out.ngc | grep min_y | cut -f2 -d' '`
  35. echo "# $minx $miny"
  36. #shiftx="-50"
  37. #shifty="-40"
  38. shiftx="-85"
  39. shifty="-10"
  40. grecode -shift -$minx -$miny out.ngc | \
  41. grecode -shift $shiftx $shifty | \
  42. sed 's/^G0\(.*\)/G0 Z1\nG0\1\nG1 Z-1/' | \
  43. sed 's/^[gG]1\(.*\)/G1\1 Z-1/' > out_fin.ngc
  44. cat drill.txt | \
  45. awk '{ print "G0 Z1\nG0", "X"$1, "Y"$2, "Z1\nG1 Z-1\nG0 Z1\n" }' | \
  46. grecode -cw > drill.ngc
  47. grecode -shift -$minx -$miny drill.ngc | \
  48. grecode -shift $shiftx $shifty > drill_fin.ngc
  49. cat out_fin.ngc drill_fin.ngc > fin.ngc