#!/bin/sh usage(){ echo oscad-stl2gcode matetial slicer-options file.stl ... echo echo exemple: oscad-stl2gcode pla h2 file1.stl file2.stl echo gcode will be produced in directory /tmp/stl2gcode/ echo echo material is abs or pla cd ~/.Slic3r/modes echo -n "slicer-options: " ls | while read a do mode=`basename $a .opts` if [ "$mode" != "abs" -a "$mode" != "pla" ] ; then echo -n $mode " " fi done echo exit 1 } if [ $# = 0 ]; then usage fi readorexec(){ MODEFILE=$HOME/.Slic3r/modes/$1.opts if [ ! -f $MODEFILE ] ; then echo slicer-mode %s does not exist : $MODEFILE missing >&2 echo --option-$1=unknown return fi NAMEEXT="${NAMEEXT}_$1" if test -x $MODEFILE then $MODEFILE else cat $MODEFILE fi } SLICCONFIG="--load $HOME/.Slic3r/simple.ini" SLICOPTS= NAMEEXT= if [ "$1" = "pla" -o "$1" = "abs" ] ; then NAMEEXT=_$1 SLICOPTS=`export material=$1; ~/.Slic3r/printer.opts` shift else echo First argument must be the material: pla or abs exit 1 fi while [ $# -gt 0 ] do case $1 in *.stl) break ;; *) NAMEEXT="${NAMEEXT}_$1" SLICOPTS="$SLICOPTS `readorexec $1`" shift ;; esac done if [ $# = 0 ] ; then echo No stl file supplied echo usage fi echo SLICOPTS=$SLICOPTS SLICOPTS=`oscad-optimopts -- $SLICOPTS` while [ $# -gt 0 ] do case $1 in *.stl) mkdir -p /tmp/stl2gcode gcode=/tmp/stl2gcode/`basename $1 .stl`$NAMEEXT.gcode echo slic3r $SLICCONFIG $SLICOPTS $1 -o $gcode echo slic3r $SLICCONFIG $SLICOPTS $1 -o $gcode shift ;; *) echo expect stl file name >&2 exit 1 esac done