Script to convert existing models to binary. Found a curious thing: taking one very complex file from ascii to binary increased the file size dramatically (9460%). Need to investigate if this was a specific case and whether or not this is something to investigate in other projects. The model in question is gnal_100ft_spiral_top.stl produced by current code.

This commit is contained in:
mmcwilliams 2020-08-19 15:12:02 -04:00
parent b89205614e
commit 28c7ef1bb4
1 changed files with 36 additions and 0 deletions

36
scripts/binary_convert.sh Normal file
View File

@ -0,0 +1,36 @@
#!/bin/bash
# "v1" not working as expected
VERSIONS=( "v2" "v3" )
SIZES=( "50ft" "100ft" )
for VERSION in "${VERSIONS[@]}"
do
:
for SIZE in "${SIZES[@]}"
do
:
echo "./stl/${SIZE}_${VERSION}"
FILES=./stl/${SIZE}_${VERSION}/*.stl
for stl in $FILES
do
fileSize=`wc -c < "$stl"`
fileSize=`echo $newSize | xargs`
firstline=`head -n 1 "$stl"`
if [[ $firstline == solid* ]]; then
echo "Converting $stl to binary..."
#convert from ascii to binary
admesh -c -b "$stl" "$stl"
newSize=`wc -c < "$stl"`
newSize=`echo $newSize | xargs`
percent=`echo "scale=1;($newSize/$fileSize)*100" | bc`
#fileSize="${newSize}"
echo "Binary conversion created STL file ${percent}% of original"
fi
done
done
done