summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven <steven.vasilogianis@gmail.com>2021-05-04 22:32:59 -0400
committerSteven <steven.vasilogianis@gmail.com>2021-05-04 22:32:59 -0400
commita2459db2fcc20750e113bdffebbb1674ff858774 (patch)
treefe8c150d7827517c0f02e10636ab01ade7314a1b
parent57b9553710f4e0cb30173dacf7881ce3b8b2af9c (diff)
start on generating stls from shell. probably gonna scrap most of this and parse out of cubbies.scad
-rwxr-xr-xcubbies.sh91
1 files changed, 91 insertions, 0 deletions
diff --git a/cubbies.sh b/cubbies.sh
new file mode 100755
index 0000000..c6f370c
--- /dev/null
+++ b/cubbies.sh
@@ -0,0 +1,91 @@
1#!/bin/bash
2
3openscad_cmd=openscad
4input_scad="./cubbies.scad"
5
6depth=${1:-100}
7height=${2:-80}
8width=${3:-50,45,40}
9tab_width=${4:-10}
10tab_depth=${5:-5}
11tab_height=${6:-5}
12outside_strut_thickness=${7:-5}
13inside_strut_thickness=${8:-5}
14
15split_on_commas() {
16 local IFS=,
17 local WORD_LIST=($1)
18 for word in "${WORD_LIST[@]}"; do
19 echo "$word"
20 done
21}
22
23
24echo $width;
25#for i in $(echo $width); do
26split_on_commas $width |while read i; do
27 echo $i
28done;
29exit;
30
31
32
33# split_on_commas "this,is a,list" | while read item; do
34# # Custom logic goes here
35# echo Item: ${item}
36# done
37
38function mk_params () {
39 declare -A varmap=(
40 [width]=cubby_width
41 [depth]=cubby_depth
42 [height]=cubby_height
43 [tab_width]=tab_width
44 [tab_depth]=tab_depth
45 [tab_height]=tab_height
46 [outside_strut_thickness]=outside_strut_thickness
47 [inside_strut_thickness]=inside_strut_thickness
48 );
49 #$ for K in "${!MYMAP[@]}"; do echo $K; done
50 retstr=""
51 for var in "${!varmap[@]}"; do
52 mapvar=${varmap[$var]}
53 #echo $var;
54 val=${!var}
55 retstr="${retstr} -D $mapvar=$val ";
56 done;
57
58 echo $retstr
59 #return $retstr
60}
61
62function args_to_string () {
63 echo "${width}-${depth}-${height}-${outside_strut_thickness}"
64}
65
66params=$(mk_params);
67
68parts=(separator bottom)
69dir=$(mktemp -p ./ -d output-stl.XXX)
70args_str=$(args_to_string)
71
72for part in "${parts[@]}"; do
73 output_args="-o $dir/$part-$args_str.stl";
74 cmd="$openscad_cmd $input_scad $params $output_args"
75 separator_cmd="${cmd} -D part=\"separator\""
76 #bottom_cmd="${cmd} -D part=\"bottom\""
77 IFS=',' for i in $(echo $width); do
78 bottom_cmd="$cmd $input_scad $params -D cubby_width=$i $output_args"
79 echo $bottom_cmd
80 done;
81
82 echo $seperator_cmd
83 #IFS=',' for d in
84 #echo $cmd;
85 #$cmd $input_scad $params -D part=\"${part}\" -o $dir/$part.stl
86done;
87# $ declare -A MYMAP=( [foo]=bar [baz]=quux [corge]=grault ) # Initialise all at once
88# $ echo ${MYMAP[foo]}
89# bar
90# $ echo ${MYMAP[baz]}
91# quux