diff options
author | Steven <steven.vasilogianis@gmail.com> | 2021-11-09 14:51:11 -0500 |
---|---|---|
committer | Steven <steven.vasilogianis@gmail.com> | 2021-11-09 14:51:11 -0500 |
commit | c72e2a9e105aeed24dd407ac8aa61203e3baf7c6 (patch) | |
tree | a0f01124a967863f5433c4c7eb2544c3a2d93446 | |
parent | 76aebb95a822a8e31d2ef2174b0a56efc838bf22 (diff) |
Generate a full set of cubby's from the command line
-rwxr-xr-x | cubbies.sh | 120 |
1 files changed, 34 insertions, 86 deletions
@@ -1,91 +1,39 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | openscad_cmd=openscad | 3 | usage() { |
4 | input_scad="./cubbies.scad" | 4 | cat <<EOF |
5 | 5 | $0 cubby-depth cubby-height cubby-width0 cubby-width1 cubby-widthN | |
6 | depth=${1:-100} | 6 | e.g.: |
7 | height=${2:-80} | 7 | $0 150 90 20 30 35 |
8 | width=${3:-50,45,40} | 8 | EOF |
9 | tab_width=${4:-10} | ||
10 | tab_depth=${5:-5} | ||
11 | tab_height=${6:-5} | ||
12 | outside_strut_thickness=${7:-5} | ||
13 | inside_strut_thickness=${8:-5} | ||
14 | |||
15 | split_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 | |||
24 | echo $width; | ||
25 | #for i in $(echo $width); do | ||
26 | split_on_commas $width |while read i; do | ||
27 | echo $i | ||
28 | done; | ||
29 | exit; | ||
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 | |||
38 | function 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 | |||
62 | function args_to_string () { | ||
63 | echo "${width}-${depth}-${height}-${outside_strut_thickness}" | ||
64 | } | 9 | } |
65 | 10 | ||
66 | params=$(mk_params); | 11 | [ "-h" == "$1" ] && usage && exit; |
67 | 12 | ||
68 | parts=(separator bottom) | 13 | shopenscad_cmd="./shopenscad.sh cubbies.scad " |
69 | dir=$(mktemp -p ./ -d output-stl.XXX) | 14 | |
70 | args_str=$(args_to_string) | 15 | export $(echo $($shopenscad_cmd -p)) |
71 | 16 | # # $ ./shopenscad.sh -p cubbies.scad | |
72 | for 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; | 29 | cubby_depth=$1; shift |
85 | #$cmd $input_scad $params -D part=\"${part}\" -o $dir/$part.stl | 30 | cubby_height=$1; shift |
31 | |||
32 | # echo depth: $cubby_depth | ||
33 | # echo height: $cubby_height | ||
34 | part='"side"' ${shopenscad_cmd} | ||
35 | |||
36 | for i in "$@"; do | ||
37 | part='"bottom"' ${shopenscad_cmd} | ||
38 | part='"side"' cubby_width="$i" ${shopenscad_cmd} | ||
86 | done; | 39 | done; |
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 | ||