#!/bin/sh LIST= LISTTEST= EXT=stl SLICE= SLICECONFIG=simple0.ini SLICEOPT= MATERIALOPT= NAMEEXT= VIEWSELOPT= while [ "$1" != "" ] do case $1 in --png) EXT=png shift ;; --list) LIST=on shift ;; --listtest) LISTTEST=on shift ;; --listprint) LISTPRINT=on shift ;; --slice) SLICE=on shift ;; --sliceconfig) shift SLICECONFIG=$1 shift ;; --materialmode) shift echo MATERIALMODE=$1 MODEFILE=$HOME/.Slic3r/modes/$1.opts if [ ! -f $MODEFILE ] ; then echo $MODEFILE does not exist exit 1 fi NAMEEXT="${NAMEEXT}_$1" if test -x $MODEFILE then MATERIALOPT="$MATERIALOPT `$MODEFILE`" else MATERIALOPT="$MATERIALOPT `cat $MODEFILE`" fi shift ;; --slicemode) shift echo SLICEMODE=$1 VIEWSELOPT="$VIEWSELOPT -o $1" MODEFILE=$HOME/.Slic3r/modes/$1.opts if [ ! -f $MODEFILE ] ; then echo $MODEFILE does not exist exit 1 fi NAMEEXT="${NAMEEXT}_$1" if test -x $MODEFILE then SLICEOPT="$SLICEOPT `$MODEFILE`" else SLICEOPT="$SLICEOPT `cat $MODEFILE`" fi shift ;; --sliceopt) shift SLICEOPT="$SLICEOPT $1 $2" shift shift ;; --*) echo Unknown option $1 exit 1 ;; *) break esac done if [ $# = 0 ] ; then echo buildviews.sh [ options ] scadfile [ view ... ] echo " --list" echo " --listtest" echo " --listprint" echo " --slice" echo " --sliceconfig file.ini" else file=$1 shift if [ $# = 0 ] ; then # Build all views #VIEWS=`grep "// allviews " $file | sed 's/allviews//' | sed 's.//..'` VIEWS=`oscad-readopts -o allviews $file` else VIEWS="$*" fi if [ "$LIST" = "" -a "$LISTTEST" = "" -a "$LISTPRINT" = "" ] ; then BASE=`basename $file .scad` mkdir -p /tmp/$BASE rm -f /tmp/$BASE/* echo Export parts of file $file in /tmp/$BASE for view in $VIEWS do BASENAME=/tmp/$BASE/$view # Remove the include used during editing # Copy cadlib.h in the build directory and change the include for use in none `buildviews-use $file` do if [ $use != "none" ] ; then cp $use /tmp/$BASE/. fi done if [ -f cadlib.h ] ; then cp cadlib.h /tmp/$BASE/. elif [ -f ../cadlib.h ] ; then cp ../cadlib.h /tmp/$BASE/. fi viewsel -p "!$view" -s $file $VIEWSELOPT >$BASENAME.insert ##grep -v "/tmp/viewsel/" $file | sed 's=../cadlib=cadlib=' >$BASENAME.scad buildviews-insert --insert $BASENAME.insert $file >$BASENAME.scad OUTPUT=$BASENAME.$EXT DEFVAR="-D vs_printing=true" # Extract the slicing options from the scad file and append it to the name extension for opt in none `oscad-readopts -o viewsopts $file` `oscad-readopts -o viewopts --optname2 $view $file` do if [ "$opt" != "none" ] ; then NAMEEXT="${NAMEEXT}_$opt" fi done # Extract the slicing options and convert them into slic3r options VIEWSLICEOPT="$MATERIALOPT `oscad-readopts -c -o viewsopts $file` `oscad-readopts -c -o viewopts --optname2 $view $file` $SLICEOPT" VIEWSLICEOPT=`oscad-optimopts -- $VIEWSLICEOPT` for opt in $VIEWSLICEOPT do case $opt in --layer-height=*) VAR=`echo $opt | sed s/--// | sed s/-/_/` DEFVAR="$DEFVAR -D vs_$VAR" ;; --first-layer-height=*) VAR=`echo $opt | sed s/--// | sed s/-/_/g` DEFVAR="$DEFVAR -D vs_$VAR" ;; --nozzle-diameter=*) VAR=`echo $opt | sed s/--// | sed s/-/_/g` DEFVAR="$DEFVAR -D vs_$VAR" ;; --fill-density=*) VAR=`echo $opt | sed s/--// | sed s/-/_/g` DEFVAR="$DEFVAR -D vs_$VAR" ;; esac done echo DEFVAR=$DEFVAR #echo openscad -o /tmp/$BASE/$view.$EXT -D view=\"$view\" $DEFVAR $file #openscad -o $OUTPUT -D view=\"$view\" $DEFVAR $file echo openscad -o /tmp/$BASE/$view.$EXT $DEFVAR $BASENAME.scad openscad -o $OUTPUT $DEFVAR "$BASENAME.scad" GCODEOPT="--start-gcode $HOME/.Slic3r/start-gcode --end-gcode $HOME/.Slic3r/end-gcode" if [ "$SLICE" = "on" -a "$EXT" = "stl" ] ; then echo slic3r $VIEWSLICEOPT $GCODEOPT $OUTPUT -o ${BASENAME}$NAMEEXT.gcode slic3r $VIEWSLICEOPT $GCODEOPT $OUTPUT -o ${BASENAME}$NAMEEXT.gcode fi done elif [ "$LIST" = "on" ] ; then oscad-readopts -o allviews --splitline --printdesc $file | sort elif [ "$LISTTEST" = "on" ] ; then oscad-readopts -o testviews --splitline --printdesc $file | sort elif [ "$LISTPRINT" = "on" ] ; then oscad-readopts -o printviews --splitline --printdesc $file | sort fi fi