summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven <steven.vasilogianis@gmail.com>2021-10-26 18:15:41 -0400
committerSteven <steven.vasilogianis@gmail.com>2021-10-26 18:17:09 -0400
commit6f92c0d40fc78e66a2973b9f8c5af9ca3849e2c8 (patch)
tree526b9e67e8b7fba88a7074c59132a5fa65d33473
parent6cbd9460671d9348d77259c9d11e14e73546f733 (diff)
Use BOSL2 library for dovetails, inscribe tolerance on tolerance test pieces. and other stuff
-rw-r--r--cubbies.scad244
1 files changed, 132 insertions, 112 deletions
diff --git a/cubbies.scad b/cubbies.scad
index fdd4eb8..99b2f4d 100644
--- a/cubbies.scad
+++ b/cubbies.scad
@@ -1,88 +1,119 @@
1include <BOSL2/std.scad>; // https://github.com/revarbat/BOSL2 1include <BOSL2/std.scad>; // https://github.com/revarbat/BOSL2
2include <BOSL2/walls.scad>; 2include <BOSL2/walls.scad>;
3include <BOSL2/fnliterals.scad>;
4include <BOSL2/joiners.scad>;
3 5
4$fn=20; 6$fn=100;
5 7
6part="divider"; // [both:Bottom + Divider,bottom::Bottom Only,divider:Divider Only,male tab line:Line of male tabs,female tab line: Line of female tabs,view_fit_test:Generate a model to view tab fit (for debugging)] 8part="side test fit"; // [both:Bottom + Side,bottom::Bottom Only,side:Side Only,view_fit:Debugging view to confirm tab fit,bottom_tabs:Tabs only from bottom,side_tabs:Holes only from side]
7 9
8/* [Cubby dimensions] */ 10/* [Cubby dimensions] */
9cubby_width=50; 11cubby_width=150;
10cubby_depth=180; 12cubby_depth=120;
11cubby_divider_height=90; 13cubby_height=90;
12 14
13// thickness of both bottom + dividers 15// thickness of bottom and side
14thickness=5; 16thickness=5;
15 17
16// thickness of struts 18// thickness of struts (used in both bottom and side)
17strut_thickness=5; 19strut_thickness=5;
18 20
21// If set (to non zero), this is used in the max_bridge paramater for the
22// sparse_struct BOSL 2 function (which generates the wireframe rectangles). By
23// default, it is calculated as max_bridge=(cubby_height + cubby_width)/5.
24max_bridge=0;
25
19/* [Tab Dimensions] */ 26/* [Tab Dimensions] */
20tab_width=10; 27tab_width=10;
21tab_padding=5; 28tab_padding=5; // minimum material between tabs
22tab_tolerance=0.5; 29tab_tolerance=0.5;
23 30
31/* [Used only in tab fit tests] */
32// Smallest tolerance
33//tolerance_start=0.5;
34// Largest tolerance
35//tolerance_end=1.0;
36// Steps to increment from smallest to largest tolerance
37//tolerance_step=0.1;
38/* [Screw Tabs] */
39screw_tabs=true;
40
24/* [Hidden] */ 41/* [Hidden] */
25tab_depth=thickness; 42tab_depth=thickness;
26tab_height=thickness; 43tab_height=thickness;
27 44
28 45/* text inscribed (when printing tolerances) */
29if ( part == "bottom" ) { 46text_extrude=2;
30 rot(90) yrot(90) cubby_bottom(cubby_width, cubby_depth); 47text_size=thickness * 0.8;
31} else if ( part == "divider" ) { 48
32 yrot(180+90) cubby_divider(cubby_depth, cubby_divider_height); 49
33} else if ( part == "male tab line" ) { 50if ( part == "both" ) {
34 print_tab_line(cubby_width, cubby_depth, cubby_divider_height, male=true); 51 both();
35} else if ( part == "female tab line" ) { 52} else if ( part =="bottom") {
36 print_tab_line(cubby_width, cubby_depth, cubby_divider_height, male=false); 53 cubby_bottom(cubby_width, cubby_depth);
37} else if ( part == "male tab" ) { 54} else if ( part == "side" ) {
38 print_single_tab(male=true); 55 cubby_side(cubby_depth, cubby_height, screw_tabs);
39} else if ( part == "female tab") { 56} else if ( part == "view_fit") {
40 print_single_tab(male=false); 57 view_tab_fit(cubby_width, cubby_depth, cubby_height);
41} else if ( part == "view fit test") { 58} else if ( part == "bottom_tabs" ) {
42 view_tab_fit(cubby_width, cubby_depth, cubby_divider_height); 59 bottom_test_fit(cubby_width, cubby_depth);
43} else if ( part == "both") { 60} else if ( part == "side_tabs" ) {
44 cubby(cubby_width, cubby_depth, cubby_divider_height); 61 side_test_fit(cubby_depth, cubby_height);
45} 62}
46 63
47module cubby (w, d, h) { 64function double (x) = x * 2;
48 position_flat() children(); 65function half (x) = x / 2;
49 66
50 module position_flat () { 67module both () {
51 rot(90) yrot(90) cubby_bottom(w, d); 68 gap=5;
52 gap=5; 69 cubby_bottom(cubby_width, cubby_depth);
53 yrot(180+90) { 70 left(((cubby_width + cubby_height) / 2) + (tab_height * 2) + gap)
54 down(((w + h) / 2) + (tab_height * 2) + gap) cubby_divider(d, h); 71 cubby_side(cubby_depth, cubby_height, screw_tabs);
55 } 72}
56 } 73
74module cubby_bottom (width, depth) {
75 rot(90) yrot(90) color("blue") bottom_wall() yrot(90) down(tab_height / 2) {
76 move_dist=width / 2 + (tab_depth / 2);
77 fwd(move_dist)
78 alternating_tabs(false, "male", depth, tab_width,
79 tab_depth, tab_height, tab_padding, tab_tolerance);
80 back(move_dist)
81 alternating_tabs(true, "male", depth, tab_width,
82 tab_depth, tab_height, tab_padding, tab_tolerance);
83 }
84 children();
85 module bottom_wall () {
86 strut_wall(width, depth) children();
87 }
57} 88}
58 89
59module cubby_divider (depth, height, screw_tabs=true) { 90/* this calculation needs to be referenced by the view_tab_fit function */
60 function bracket_height() = thickness * 2; 91function cubby_side_bracket_height() = double(tab_height) + tab_tolerance;
92module cubby_side (depth, height, screw_tabs=true) {
61 screw_tab_width=15; 93 screw_tab_width=15;
62 screw_tab_height=20; 94 screw_tab_height=20;
63 screw_tab_thickness=thickness; 95 screw_tab_thickness=thickness;
64 96
65 divider_wall() { 97 yrot(180+-90) color("red") side_wall() {
66 if ( screw_tabs ) { 98 if ( screw_tabs ) {
67 position(TOP+FRONT+LEFT) screw_tab(); 99 position(TOP+FRONT+LEFT) screw_tab();
68 up(screw_tab_height) position(BOTTOM+FRONT+LEFT) screw_tab(); 100 up(screw_tab_height) position(BOTTOM+FRONT+LEFT) screw_tab();
69 } 101 }
70 attach(BOTTOM, TOP) zrot(90) tab_bracket(); 102 attach(BOTTOM, TOP) zrot(90) tab_bracket();
71 attach(TOP, BOTTOM) zrot(90) tab_bracket(); 103 attach(TOP, BOTTOM) zrot(90) tab_bracket();
72 } 104 }
73 children(); 105 children();
74 106
75 module divider_wall () { 107 module side_wall () {
76 strut_wall(depth, height - bracket_height()) children(); 108 strut_wall(depth, height - cubby_side_bracket_height() * 2) children();
77 } 109 }
78 110
79 module tab_bracket () { 111 module tab_bracket () {
80 difference() { 112 difference() {
81 cuboid([depth,thickness,bracket_height()]); 113 cuboid([depth,thickness,cubby_side_bracket_height()]);
82 add_tabs(depth, male=false, between=false); 114 alternating_tabs(true, "female", depth, tab_width, tab_depth, tab_height, tab_padding, tab_tolerance);
83 add_tabs(depth, male=false, between=true); 115 alternating_tabs(false, "female", depth, tab_width, tab_depth, tab_height, tab_padding, tab_tolerance);
84 } 116 }
85
86 children(); 117 children();
87 } 118 }
88 119
@@ -91,8 +122,8 @@ module cubby_divider (depth, height, screw_tabs=true) {
91 cuboid([screw_tab_width, screw_tab_thickness,screw_tab_height], 122 cuboid([screw_tab_width, screw_tab_thickness,screw_tab_height],
92 anchor=LEFT+TOP); 123 anchor=LEFT+TOP);
93 right(screw_tab_width * (2 / 3)) zrot(90) yrot(90) { 124 right(screw_tab_width * (2 / 3)) zrot(90) yrot(90) {
94 right(screw_tab_height * (1 / 3)) #cyl(l=15, r=2, anchor=RIGHT); 125 right(screw_tab_height * (1 / 3)) cyl(l=15, r=2, anchor=RIGHT);
95 right(screw_tab_height * (2 / 3)) #cyl(l=15, r=2, anchor=LEFT); 126 right(screw_tab_height * (2 / 3)) cyl(l=15, r=2, anchor=LEFT);
96 } 127 }
97 128
98 } 129 }
@@ -100,79 +131,68 @@ module cubby_divider (depth, height, screw_tabs=true) {
100 } 131 }
101} 132}
102 133
103module cubby_bottom (width, depth) {
104 color("blue") {
105 bottom_wall();
106 yrot(90) {
107 move_dist=width / 2 + (tab_depth / 2);
108 fwd(move_dist)
109 add_tabs(depth, male=true, between=false);
110 back(move_dist)
111 add_tabs(depth, male=true, between=true);
112 }
113 }
114 children();
115
116 module bottom_wall () {
117 strut_wall(width, depth) children();
118 }
119}
120
121module strut_wall(w, h) { 134module strut_wall(w, h) {
135 bridge=max_bridge ? max_bridge : (h+w)/5;
122 sparse_strut( 136 sparse_strut(
123 l=w, 137 l=w,
124 h=h, 138 h=h,
125 thick=thickness, 139 thick=thickness,
126 maxang=45, 140 maxang=45,
127 strut=5, 141 strut=5,
128 max_bridge=(h+w)/5 142 max_bridge=bridge
129 ) children(); 143 ) children();
130} 144}
131 145
146module bottom_test_fit (w, d) {
147 keep=(w / 2) - thickness;
148 //right_half(x=keep) cubby_bottom(cubby_width, cubby_depth);
132 149
133function tab_spacing (tab_width) = tab_width * 3.5; 150 text=str("t=", tab_tolerance);
134 151 text_pos=[(-w / 2) + (thickness * 0.9),
135module single_tab ( 152 -d / 2 + thickness,
136 tab_width=10, 153 (thickness / 2) - text_extrude];
137 tab_depth=5, 154
138 tab_height=5, 155 difference() {
139 male=true, 156 left_half(x=-keep) cubby_bottom(cubby_width, cubby_depth);
140 tolerance=1 157 #translate(text_pos) zrot(90) linear_extrude(text_extrude) color("green") text(size=text_size, text);
141) {
142 size=male
143 ? [tab_width, tab_depth, tab_height]
144 : [tab_width + tolerance, tab_depth + tolerance, tab_height + tolerance];
145 if (male) {
146 #cuboid(size) children();
147 } else {
148 cuboid(size) children();
149 } 158 }
150} 159}
151 160
152/* module single_hole ( size_of_yo_hole = 2000mm ) { */ 161module side_test_fit (d, h) {
153/* if (male) { */ 162 text=str("t=", tab_tolerance);
154/* #cylinder(size_of_yo_hole) children(); */ 163 text_pos=[-h/2 + (thickness * 0.9),
155/* } else { */ 164 -d / 2 + thickness,
156/* cylinder(size_of_yo_hole) children(); */ 165 (thickness / 2) - text_extrude];
157/* } */ 166
158 167 difference() {
159/* } */ 168 left_half(x=(h / -2 + (thickness * 3)))
160 169 cubby_side(d, h, screw_tabs=false);
161module tab_line ( 170 #translate(text_pos) zrot(90) linear_extrude(text_extrude) color("green") text(size=text_size, text);
162 distance=100, 171 }
163 tab_width=10, 172}
164 tab_depth=5, 173
165 tab_height=5, 174module view_tab_fit (w, d, h) {
166 tab_padding=5, 175 // position for testing tab fit
167 male=true, 176 module position_fit_test (left=true) {
168 tolerance=1, 177 cubby_bottom(w, d);
169 edge_padding=0, 178 dist=(w / 2) + (thickness / -2) + tab_depth - 2;
170 between=false, 179 down=half(h) - half(thickness) - tab_height - half(tab_tolerance);
171) { 180 yflip() yrot(90) down(dist * (left ? 1 : -1)) left(down) cubby_side(d, h, screw_tabs);
172 start = between ? ((tab_padding * 2) + tab_width) : tab_padding; 181 }
173 tab_spacing = (tab_width * 2) + (tab_padding * 2); 182
174 shift = (distance - (tab_padding * 2)) / -2; 183 position_fit_test(left=true);
175 for ( i = [shift+start:tab_spacing:(shift * -1) - tab_padding] ) { 184 yrot(180) up(h) position_fit_test(left=false);
176 right(i) #single_tab(tab_width, tab_depth, tab_height, male, tolerance); 185}
177 } 186
187module alternating_tabs ( first, gender, length, tab_width, tab_depth, tab_height, tab_padding, tolerance ) {
188 dist=length - (tab_padding * 2);
189 total_tabs=dist / (tab_width + tab_padding + tolerance);
190 half_tabs=total_tabs / 2;
191 tab_qty = total_tabs % 2 == 0 ? half_tabs : first ? ceil(half_tabs) : floor(half_tabs);
192 start = first ? tab_padding : (tab_padding * 2) + tab_width;
193 spacing = (tab_width + tab_padding) * 2;
194 xcopies(spacing, tab_qty, dist, sp=((dist / -2) + start))
195 #dovetail(gender, angle=0, slide=add_tol(tab_depth), width=add_tol(tab_width), height=add_tol(tab_height));
196
197 function add_tol (x) = gender == "male" ? x : x + tolerance;
178} 198}