From 03059f7c5c62bfc0d4881fe31f449bb5aaf69714 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Thu, 20 Aug 2020 08:35:12 -0400 Subject: [PATCH] Add a script that generates a pov model from an stl but gives it the proper name (of the file). Using this to build renders of the models for launch (tomorrow?) --- scripts/stl2pov.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 scripts/stl2pov.sh diff --git a/scripts/stl2pov.sh b/scripts/stl2pov.sh new file mode 100644 index 0000000..ea83207 --- /dev/null +++ b/scripts/stl2pov.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +INPUT="$1" +OUTPUT="$2" + +if [ "$INPUT" = "" ]; then + exit 1 +fi + +if [ "$OUTPUT" = "" ]; then + exit 1 +fi + +FILE_NAME=`basename "${INPUT}" .stl` +TMP_FILE=`mktemp` + +stl2pov "${INPUT}" > "${TMP_FILE}" + +DECLARE_LINE=`cat "${TMP_FILE}" | grep "^#declare "` +MODEL_NAME=`echo "${DECLARE_LINE}" | awk '{print $2}'` +NEW_LINE=`echo $DECLARE_LINE | sed "s/${MODEL_NAME}/${FILE_NAME}/g"` + +cat "${TMP_FILE}" | sed "s/$DECLARE_LINE/$NEW_LINE/" > "${OUTPUT}" + +rm "${TMP_FILE}" +echo "${FILE_NAME}" \ No newline at end of file