summaryrefslogtreecommitdiff
path: root/cubbies.scad
blob: fdd4eb80d1c4832a7e3cf220269d18cfebe5706e (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
include <BOSL2/std.scad>;       // https://github.com/revarbat/BOSL2
include <BOSL2/walls.scad>;

$fn=20;

part="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)]

/* [Cubby dimensions] */
cubby_width=50;
cubby_depth=180;
cubby_divider_height=90;

// thickness of both bottom + dividers
thickness=5;

// thickness of struts
strut_thickness=5;

/* [Tab Dimensions] */
tab_width=10;
tab_padding=5;
tab_tolerance=0.5;

/* [Hidden] */
tab_depth=thickness;
tab_height=thickness;


if ( part == "bottom" ) {
     rot(90) yrot(90) cubby_bottom(cubby_width, cubby_depth);
} else if ( part == "divider" ) {
     yrot(180+90) cubby_divider(cubby_depth, cubby_divider_height);
} else if ( part == "male tab line" ) {
     print_tab_line(cubby_width, cubby_depth, cubby_divider_height, male=true);
} else if ( part == "female tab line" ) {
     print_tab_line(cubby_width, cubby_depth, cubby_divider_height, male=false);
} else if ( part == "male tab" ) {
     print_single_tab(male=true);
} else if ( part == "female tab") {
     print_single_tab(male=false);
} else if ( part == "view fit test") {
     view_tab_fit(cubby_width, cubby_depth, cubby_divider_height);
} else if ( part == "both") {
     cubby(cubby_width, cubby_depth, cubby_divider_height);
}

module cubby (w, d, h) {
     position_flat() children();

     module position_flat () {
          rot(90) yrot(90) cubby_bottom(w, d);
          gap=5;
          yrot(180+90) {
               down(((w + h) / 2) + (tab_height * 2) + gap) cubby_divider(d, h);
          }
     }
}

module cubby_divider (depth, height, screw_tabs=true) {
     function bracket_height() = thickness * 2;
     screw_tab_width=15;
     screw_tab_height=20;
     screw_tab_thickness=thickness;

     divider_wall() {
          if ( screw_tabs ) {
               position(TOP+FRONT+LEFT) screw_tab();
               up(screw_tab_height) position(BOTTOM+FRONT+LEFT) screw_tab();
          }
          attach(BOTTOM, TOP)  zrot(90) tab_bracket();
          attach(TOP, BOTTOM)  zrot(90) tab_bracket();
     }
     children();

     module divider_wall () {
          strut_wall(depth, height - bracket_height()) children();
     }

     module tab_bracket () {
          difference() {
               cuboid([depth,thickness,bracket_height()]);
               add_tabs(depth, male=false, between=false);
               add_tabs(depth, male=false, between=true);
          }

          children();
     }

     module screw_tab () {
          difference() {
               cuboid([screw_tab_width, screw_tab_thickness,screw_tab_height],
                      anchor=LEFT+TOP);
               right(screw_tab_width * (2 / 3)) zrot(90) yrot(90) {
                    right(screw_tab_height * (1 / 3)) #cyl(l=15, r=2, anchor=RIGHT);
                    right(screw_tab_height * (2 / 3)) #cyl(l=15, r=2, anchor=LEFT);
               }

          }
          children();
     }
}

module cubby_bottom (width, depth) {
     color("blue") {
          bottom_wall();
          yrot(90) {
               move_dist=width / 2 + (tab_depth / 2);
               fwd(move_dist)
                    add_tabs(depth, male=true, between=false);
               back(move_dist)
                    add_tabs(depth, male=true, between=true);
          }
     }
     children();

     module bottom_wall () {
          strut_wall(width, depth) children();
     }
}

module strut_wall(w, h) {
     sparse_strut(
          l=w,
          h=h,
          thick=thickness,
          maxang=45,
          strut=5,
          max_bridge=(h+w)/5
    ) children();
}


function tab_spacing (tab_width) = tab_width * 3.5;

module single_tab (
     tab_width=10,
     tab_depth=5,
     tab_height=5,
     male=true,
     tolerance=1
) {
     size=male
          ? [tab_width, tab_depth, tab_height]
          : [tab_width + tolerance, tab_depth + tolerance, tab_height + tolerance];
     if (male) {
          #cuboid(size) children();
     } else {
          cuboid(size) children();
     }
}

/* module single_hole ( size_of_yo_hole = 2000mm )  { */
/*      if (male) { */
/*           #cylinder(size_of_yo_hole) children(); */
/*      } else { */
/*           cylinder(size_of_yo_hole) children(); */
/*      } */

/* } */

module tab_line (
     distance=100,
     tab_width=10,
     tab_depth=5,
     tab_height=5,
     tab_padding=5,
     male=true,
     tolerance=1,
     edge_padding=0,
     between=false,
) {
     start = between ? ((tab_padding * 2) + tab_width) : tab_padding;
     tab_spacing = (tab_width * 2) + (tab_padding * 2);
     shift = (distance - (tab_padding * 2)) / -2;
     for ( i = [shift+start:tab_spacing:(shift * -1) - tab_padding] ) {
          right(i) #single_tab(tab_width, tab_depth, tab_height, male, tolerance);
     }
}