-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-stls.sh
executable file
·77 lines (62 loc) · 1.51 KB
/
make-stls.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
if ! command -v openscad &> /dev/null; then
echo 'OpenSCAD binary not found on path.'
exit -1
fi
fileExists() {
if [ "${force}" != true ] && [ -f "${1}" ]; then
echo "File ${file} exists but '-f' flag not set -- skipping."
true
else
false
fi
}
# read params
while test $# != 0; do
case "$1" in
-f) force=true ;;
-o) outDir=$2; shift ;;
*) extraOptions="${extraOptions} $1" ;;
esac
shift
done
outDir=${outDir:=out/stl}
options="--hardwarnings --check-parameters true --check-parameter-ranges true ${extraOptions} ./bb-brix.scad"
# 1x & 2x bricks
for x in 1 2; do
for y in {1..6}; do
if [ "${x}" == 2 ] && [ "${y}" == 1 ]; then
continue
else
file="${outDir}/bb-brix_${x}x${y}.stl"
echo
if ! fileExists ${file}; then
echo "Generating ${x}x${y} brick..."
openscad -o ${file} -D 'action="brick"' -D "x=${x}" -D "y=${y}" ${options}
fi
fi
done
done
# "L" bricks
for x in {2..6}; do
for y in {2..6}; do
file="${outDir}/bb-brix_l_${x}x${y}.stl"
echo
if ! fileExists ${file}; then
echo "Generating ${x}x${y} 'L' brick..."
openscad -o ${file} -D 'action="brick-l"' -D "x=${x}" -D "y=${y}" ${options}
fi
done
done
# "T" bricks
for x in 3 5; do
for y in {2..6}; do
offset=$(( (${x} + 1) / 2 ))
file="${outDir}/bb-brix_t_${x}x${y}@${offset}.stl"
echo
if ! fileExists ${file}; then
echo "Generating ${x}x${y}@${offset} 'T' brick..."
openscad -o ${file} -D 'action="brick-t"' -D "x=${x}" -D "y=${y}" -D "offset=${offset}" ${options}
fi
done
done