svg2ngc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. inpsvg="$1"
  3. sf='1'
  4. if [[ "$2" != "" ]] ; then
  5. sf="$2"
  6. fi
  7. premul=`echo "1000000" | bc -l`
  8. invmul=`echo "( 1 / $premul ) * $sf" | bc -l`
  9. frapid="F800"
  10. fslow="F150"
  11. S="1.0"
  12. if [[ "$inpsvg" == "" ]] ; then
  13. echo "provide input svg"
  14. exit 1
  15. fi
  16. rawtype=`file $inpsvg`
  17. checktype=`file -b $inpsvg | cut -f1 -d' '`
  18. if [[ "$checktype" != "SVG" ]] ; then
  19. echo -e "file $inpsvg is of type:\n\n$rawtype\n\nNnot an SVG file? Exiting.\n"
  20. exit 1
  21. fi
  22. bn=`basename $inpsvg .svg`
  23. # causes duplicate paths otherwise
  24. #
  25. sed -i 's/fill="[^"]*"/fill="none"/g' $inpsvg
  26. echo "creating $bn.ps"
  27. rsvg-convert -f ps -o $bn.ps $inpsvg
  28. pstoedit -f gnuplot $bn.ps $bn.gp
  29. zplunge="-6.5"
  30. zraise="10"
  31. bitr=`echo "$premul*1.5/2" | bc -l`
  32. rm -f {$bn}-ord.gp
  33. #clipcli -s $bn.gp -F $premul -R "$bitr" -T >> ${bn}-ord.gp
  34. clipcli -s $bn.gp -F -x $premul -R "0.75" -T >> ${bn}-ord.gp
  35. rm -f ${bn}.ngc
  36. echo -e "G90\nG21\nG1 Z$zraise" >> ${bn}.ngc
  37. echo "gp2ngc --preset 3040 --z-raise "$zplunge" --z-plunge "$zraise" -i ${bn}-ord.gp -->> ${bn}.ngc"
  38. gp2ngc \
  39. --preset 3040 \
  40. --z-raise "$zraise" \
  41. --z-plunge "$zplunge" \
  42. --slow "$fslow" \
  43. --rapid "$frapid" \
  44. --premul "$invmul" \
  45. -i ${bn}-ord.gp >> ${bn}.ngc