export-all 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. VERSION=2.1.8
  3. function ngc_position {
  4. ifn="$1"
  5. offsetx=10
  6. offsety=10
  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. ngc="$bfn.$VERSION.ngc"
  29. echo "## $bfn"
  30. basedir=`dirname $( pwd ) `
  31. echo "include <$basedir/$bfn.scad>" > $tmpfn
  32. echo "${bfn}Plate();" >> $tmpfn
  33. openscad -o "$svg" "$tmpfn"
  34. svg2ngc "$svg" 2> /dev/null
  35. ngc_position "$ngc" 2> /dev/null
  36. sed -i 's/F800/F150/g' "$ngc"
  37. sed -i 's/G0\(.*\)S\(.*\)/G0\1 F5000 S\2/g' "$ngc"
  38. done
  39. rm $tmpfn