export-all 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. VERSION=2.5.0
  3. function ngc_position {
  4. ifn="$1"
  5. offsetx=10
  6. offsety=15
  7. if [[ "$ifn" == "" ]] ; then
  8. echo "provide file"
  9. exit 1
  10. fi
  11. dos2unix $ifn
  12. sed -i 's/;.*//' $ifn
  13. mx=`ngc_bounds $ifn | grep min_x | cut -f2 -d' '`
  14. my=`ngc_bounds $ifn | grep min_y | cut -f2 -d' '`
  15. shiftx=` echo "-($mx) + $offsetx" | bc -l`
  16. shifty=` echo "-($my) + $offsety" | bc -l`
  17. tfn=`mktemp`
  18. #echo "G0 F5000" > $tfn
  19. grecode -shift "$shiftx" "$shifty" $ifn | \
  20. grep -v '^(' >> $tfn 2> /dev/null
  21. mv $tfn $ifn
  22. rm -f $tfn
  23. }
  24. tmpfn=`mktemp`
  25. for fn in `ls ../Popufare*.scad | grep -v PopufareHousingCommon.scad ` ; do
  26. bfn=`basename $fn .scad`
  27. svg="$bfn.$VERSION.svg"
  28. svg_z="$bfn.z.$VERSION.svg"
  29. ngc="$bfn.$VERSION.ngc"
  30. echo "## $bfn"
  31. basedir=`dirname $( pwd ) `
  32. echo "include <$basedir/$bfn.scad>" > $tmpfn
  33. echo "${bfn}Plate();" >> $tmpfn
  34. openscad -o "$svg" "$tmpfn"
  35. svg2ngc "$svg" 2> /dev/null
  36. #./svg2ngc "$svg" 2> /dev/null
  37. ngc_position "$ngc" 2> /dev/null
  38. #sed -i 's/F800/F150/g' "$ngc"
  39. #sed -i 's/G0\(.*\)S\(.*\)/G0\1 F5000 S\2/g' "$ngc"
  40. cp "$svg" "$svg_z"
  41. sed -i 's/<svg\(.*\) width="\([0-9]*\)"/<svg\1 width="\2mm"/' "$svg_z"
  42. sed -i 's/<svg\(.*\) height="\([0-9]*\)"/<svg\1 height="\2mm"/' "$svg_z"
  43. sed -i 's/ stroke-width="[^"]*"/ stroke-width=".0254"/' "$svg_z"
  44. done
  45. rm $tmpfn