summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven <steven.vasilogianis@gmail.com>2021-11-09 14:51:11 -0500
committerSteven <steven.vasilogianis@gmail.com>2021-11-09 14:51:11 -0500
commitc72e2a9e105aeed24dd407ac8aa61203e3baf7c6 (patch)
treea0f01124a967863f5433c4c7eb2544c3a2d93446
parent76aebb95a822a8e31d2ef2174b0a56efc838bf22 (diff)
Generate a full set of cubby's from the command line
-rwxr-xr-xcubbies.sh120
1 files changed, 34 insertions, 86 deletions
diff --git a/cubbies.sh b/cubbies.sh
index c6f370c..4c168ab 100755
--- a/cubbies.sh
+++ b/cubbies.sh
@@ -1,91 +1,39 @@
1#!/bin/bash 1#!/bin/bash
2 2
3openscad_cmd=openscad 3usage() {
4input_scad="./cubbies.scad" 4 cat <<EOF
5 5 $0 cubby-depth cubby-height cubby-width0 cubby-width1 cubby-widthN
6depth=${1:-100} 6 e.g.:
7height=${2:-80} 7 $0 150 90 20 30 35
8width=${3:-50,45,40} 8EOF
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} 9}
65 10
66params=$(mk_params); 11[ "-h" == "$1" ] && usage && exit;
67 12
68parts=(separator bottom) 13shopenscad_cmd="./shopenscad.sh cubbies.scad "
69dir=$(mktemp -p ./ -d output-stl.XXX) 14
70args_str=$(args_to_string) 15export $(echo $($shopenscad_cmd -p))
71 16# # $ ./shopenscad.sh -p cubbies.scad
72for part in "${parts[@]}"; do 17# tab_padding=5
73 output_args="-o $dir/$part-$args_str.stl"; 18# tab_width=10
74 cmd="$openscad_cmd $input_scad $params $output_args" 19# max_bridge=0
75 separator_cmd="${cmd} -D part=\"separator\"" 20# # cubby_width=150
76 #bottom_cmd="${cmd} -D part=\"bottom\"" 21# # cubby_depth=120
77 IFS=',' for i in $(echo $width); do 22# strut_thickness=5
78 bottom_cmd="$cmd $input_scad $params -D cubby_width=$i $output_args" 23# screw_tabs=true
79 echo $bottom_cmd 24# # cubby_height=90
80 done; 25# #part="both"
81 26# thickness=3
82 echo $seperator_cmd 27# tab_tolerance=0.5
83 #IFS=',' for d in 28
84 #echo $cmd; 29cubby_depth=$1; shift
85 #$cmd $input_scad $params -D part=\"${part}\" -o $dir/$part.stl 30cubby_height=$1; shift
31
32# echo depth: $cubby_depth
33# echo height: $cubby_height
34part='"side"' ${shopenscad_cmd}
35
36for i in "$@"; do
37 part='"bottom"' ${shopenscad_cmd}
38 part='"side"' cubby_width="$i" ${shopenscad_cmd}
86done; 39done;
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