blob: c6f370c11c5e598486060fd1af83eb438354a619 (
plain)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#!/bin/bash
openscad_cmd=openscad
input_scad="./cubbies.scad"
depth=${1:-100}
height=${2:-80}
width=${3:-50,45,40}
tab_width=${4:-10}
tab_depth=${5:-5}
tab_height=${6:-5}
outside_strut_thickness=${7:-5}
inside_strut_thickness=${8:-5}
split_on_commas() {
local IFS=,
local WORD_LIST=($1)
for word in "${WORD_LIST[@]}"; do
echo "$word"
done
}
echo $width;
#for i in $(echo $width); do
split_on_commas $width |while read i; do
echo $i
done;
exit;
# split_on_commas "this,is a,list" | while read item; do
# # Custom logic goes here
# echo Item: ${item}
# done
function mk_params () {
declare -A varmap=(
[width]=cubby_width
[depth]=cubby_depth
[height]=cubby_height
[tab_width]=tab_width
[tab_depth]=tab_depth
[tab_height]=tab_height
[outside_strut_thickness]=outside_strut_thickness
[inside_strut_thickness]=inside_strut_thickness
);
#$ for K in "${!MYMAP[@]}"; do echo $K; done
retstr=""
for var in "${!varmap[@]}"; do
mapvar=${varmap[$var]}
#echo $var;
val=${!var}
retstr="${retstr} -D $mapvar=$val ";
done;
echo $retstr
#return $retstr
}
function args_to_string () {
echo "${width}-${depth}-${height}-${outside_strut_thickness}"
}
params=$(mk_params);
parts=(separator bottom)
dir=$(mktemp -p ./ -d output-stl.XXX)
args_str=$(args_to_string)
for part in "${parts[@]}"; do
output_args="-o $dir/$part-$args_str.stl";
cmd="$openscad_cmd $input_scad $params $output_args"
separator_cmd="${cmd} -D part=\"separator\""
#bottom_cmd="${cmd} -D part=\"bottom\""
IFS=',' for i in $(echo $width); do
bottom_cmd="$cmd $input_scad $params -D cubby_width=$i $output_args"
echo $bottom_cmd
done;
echo $seperator_cmd
#IFS=',' for d in
#echo $cmd;
#$cmd $input_scad $params -D part=\"${part}\" -o $dir/$part.stl
done;
# $ declare -A MYMAP=( [foo]=bar [baz]=quux [corge]=grault ) # Initialise all at once
# $ echo ${MYMAP[foo]}
# bar
# $ echo ${MYMAP[baz]}
# quux
|