diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..849dfc9 --- /dev/null +++ b/Makefile @@ -0,0 +1,57 @@ +################### +# +# takeup module OpenSCAD Makefile +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +################### + +PREFIX=takeup + +OPENSCAD=openscad +OPENSCAD_OPTIONS=-D VERBOSE=false +OPENSCAD_IMAGE_OPTIONS=--imgsize=1024,1024 --colorscheme=DeepOcean + +STL=./stl +IMG=./img +MODELS=$(shell bash ./parseVars.sh PART) + +all: directories models + +directories: + mkdir -p $(STL) + +models: directories $(MODELS) moveall + +clean: + rm -f $(STL)/$(PREFIX)_* + rm -f $(IMG)/$(PREFIX)_* + +cleanall: + rm -rf $(STL) + rm -rf $(IMG) + +moveall: + mv ./*.png ./img/ + +# Dependencies for models + +$(MODELS) : $(STL)/$(PREFIX)_%.stl : $(PREFIX).scad + $(OPENSCAD) $(OPENSCAD_OPTIONS) -o $@ -D PART=\"$(subst $(PREFIX)_,,$(subst .stl,,$(@F)))\" $< + $(OPENSCAD) $(OPENSCAD_OPTIONS) $(OPENSCAD_IMAGE_OPTIONS) -o $(subst $(STL),$(IMG)},$(subst .stl,.png,$(@F))) -D PART=\"$(subst $(PREFIX)_,,$(subst .stl,,$(@F)))\" $< diff --git a/build.sh b/build.sh deleted file mode 100644 index 9d3ac9b..0000000 --- a/build.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -mkdir -p stl -mkdir -p img - -SCAD="./takeup.scad" -PARTS=( - "slip_coupling" - "magnetic_coupling" - "mount_plate" - "daylight_spool_insert" -) - -for part in "${PARTS[@]}" -do - stl="./stl/takeup_${part}.stl" - png="./img/takeup_${part}.png" - openscad -o "${stl}" -D "PART=\"${part}\";" "${SCAD}" - openscad -o "${png}" -D "PART=\"${part}\";" --imgsize=1024,1024 --colorscheme=DeepOcean "${SCAD}" -done - -openscad --preview -o debug.png -D "PART=\"preview\";" "${SCAD}" \ No newline at end of file diff --git a/parseVars.sh b/parseVars.sh new file mode 100644 index 0000000..cf40d6c --- /dev/null +++ b/parseVars.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +STOPWORD="${1}" +FILE=$(mktemp) +TMPFILE=$(mktemp) + +cat takeup.scad | grep -e "${STOPWORD} ==" | awk -F'== "' '{print $2}' | awk -F'"' '{print $1}' > ${TMPFILE} +cat ${TMPFILE} | sed 's/^/.\/stl\/takeup_/' | sed 's/$/.stl/' > ${FILE} + +rm -f ${TMPFILE} +cat ${FILE} | tr '\n' ' ' +rm -f ${FILE} \ No newline at end of file