chiark / gitweb /
knifeblock: introduce width() (nfc)
[reprap-play.git] / knifeblock.scad
1 // -*- C -*-
2
3 // properties of the knives
4 nknives = 3;
5 widths = [15.5, 15.8, 19.0];
6 handlelenbase = 75;
7 handlelendelta = [-15, 0, 10];
8 locations = [-35, 0, 40];
9 bladew = 5; // 2.5
10 maxhandledepth = 45;
11
12 templatescale = 27.2 / 19.6;
13
14 coverlonglen = 120; // xxx
15 covershortlen = 70; // xxx
16
17 // other tuneables
18 front = 5;
19 back = 5;
20 height = 50;
21 minsidein = 4;
22 minsideout = 4;
23
24 frontbackslop = 0.25;
25
26 screwbackdepth = 6.0 - 1.0;
27 screwdia =       4.0 + 0.5;
28 screwcsinkdia =  9.8 + 1.0;
29
30 screwabove = 15;
31
32 coverthick = 2.4;
33 coverside = coverthick;
34
35 covertopwing = 15;
36 covertopwingbase = 20;
37 coveredge = 3;
38
39 holesize = 12.5;
40 holestrut = 7;
41 holeedge = 4;
42
43 holeoffx = 0.45;
44 holeoffy = 0.25;
45
46 pegstem = 3.5;
47 peghead = 10;
48 pegstemheight = 2;
49 pegheight = 9;
50 peglen = 12;
51
52 recessblockwidth = peghead + pegstem*3;
53 recessblockheight = peglen/2 + pegstem*1.5;
54
55 pegsloph = 0.5;
56 pegslopv = 0.5;
57 pegslopl = 0.5;
58
59 pegdepthproportion = 0.80;
60
61 // computed
62
63 function width(k) = widths[k];
64
65 side = minsidein + screwcsinkdia + minsideout;
66 totaldepth = front + maxhandledepth + back;
67
68 minkx = locations[0] -         width(0)        /2;
69 maxkx = locations[nknives-1] + width(nknives-1)/2;
70
71 minx = minkx - side;
72 maxx = maxkx + side;
73
74 holepitch = holesize+holestrut;
75
76 pegrecess = pegdepthproportion*totaldepth - 0.5*peglen;
77
78 module ImportTemplate(w,k,t) {
79   fn = str("knifeblock-knives-t",k,t,".dxf");
80   echo(fn);
81   translate([0,0, -w/2])
82     linear_extrude(height=w)
83     scale(templatescale) import(file=fn, convexity=100);
84 }
85
86 module Knife(k){
87   ImportTemplate(bladew, k,"bl");
88   hull(){
89     ImportTemplate(width(k), k,"hl");
90     translate([-100,0,0])
91       ImportTemplate(width(k), k,"hl");
92   }
93 }
94
95 module DoKnife(k){
96   translate([locations[k],0,0]){
97     rotate([0,90,0])
98       translate([-(handlelenbase + handlelendelta[k]),0,0])
99       Knife(k);
100   }
101 }
102
103 module DoKnives(){
104   for (k=[0:nknives-1])
105     DoKnife(k);
106 }
107
108 module ScrewHole(){
109   translate([0,-50,0])
110     rotate([-90,0,0])
111     cylinder(r=screwdia/2, h=150, $fn=40);
112   translate([0, totaldepth-front - screwbackdepth, 0])
113     rotate([90,0,0])
114     cylinder(r=screwcsinkdia/2 / (sqrt(3)/2), h=100, $fn=6);
115 }
116
117 module PegTemplate(apex){
118   for (mx=[0,1]) for (my=[0,1]) {
119       mirror([mx,0,0]) mirror([0,my,0])
120         polygon([[-0.1,      -0.1],
121                  [pegstem/2, -0.1],
122                  [pegstem/2, pegstemheight/2],
123                  [peghead/2, pegheight    /2],
124                  [-0.1,      pegheight    /2 + apex]]);
125     }
126 }
127
128 module AtSides(){
129   translate([minx,0,0])                 child(0);
130   translate([maxx,0,0]) mirror([1,0,0]) child(1);
131 }
132
133 module BlockPegSlot(){
134   translate([recessblockwidth/2, pegrecess - 0.5*peglen, -height]){
135     rotate([-90,0,0]) linear_extrude(height=totaldepth){
136       PegTemplate(peghead/2 * 1.2);
137     }
138   }
139 }
140
141 module Block(){
142   sidemidx = minsideout + screwcsinkdia/2;
143
144   difference(){
145     mirror([0,0,1]) {
146       translate([minx, -front, 0])
147         cube([maxx-minx, totaldepth, height]);
148     }
149     for (x=[minx + sidemidx, maxx - sidemidx]) {
150       translate([x, 0, -screwabove])
151         ScrewHole();
152     }
153     for (yshift=[-1,1])
154       translate([0, yshift * frontbackslop, 0])
155         DoKnives();
156     AtSides() { BlockPegSlot(); BlockPegSlot(); }
157   }
158 }
159
160 module BlockPrint(){ ////toplevel
161   rotate([0,0,90])
162     Block();
163 }
164
165 module CoverTemplate(){
166   linear_extrude(height=coverthick)
167     polygon([[minx, 0],
168              [maxx, 0],
169              [maxx, coverlonglen],
170              [maxx - coverside, coverlonglen],
171              [minx, covershortlen]]);
172 }
173
174 module CoverSide(len){
175   translate([0, 0 ,0]) {
176     rotate([90,0,90])
177       linear_extrude(height=coverside)
178       polygon([[0,                      0],
179                [0,                      totaldepth],
180                [covertopwing,           totaldepth],
181                [covertopwingbase,       coverside + coverthick],
182                [len - covertopwingbase, coverside + coverthick],
183                [len - covertopwing,     totaldepth],
184                [len,                    totaldepth],
185                [len,                    0]]);
186     cube([recessblockwidth, recessblockheight, totaldepth]);
187   }
188 }
189
190 module Peg(){
191   echo("peg angle slope (must be <1)",
192        (peghead-pegstem)/(pegheight-pegstemheight));
193   dx = pegsloph;
194   dy = pegslopv;
195   rotate([90,0,0]) {
196     linear_extrude(height=peglen-pegslopl) {
197       intersection(){
198         translate([-dx,-dy,0]) PegTemplate(0);
199         translate([-dx,+dy,0]) PegTemplate(0);
200         translate([+dx,+dy,0]) PegTemplate(0);
201         translate([+dx,-dy,0]) PegTemplate(0);
202       }
203     }
204   }
205 }
206
207 module CoverPegSlot(coverlen){
208   translate([recessblockwidth/2, 0, -1]){
209     linear_extrude(height= 1 + pegrecess + 0.5*peglen){
210       PegTemplate(0);
211     }
212   }
213 }
214
215 module HoleRow(){
216   for (i=[0:10]) {
217     translate([0, (i+0.5)*holepitch, -1])
218       cylinder(r=holesize/2, h=coverthick+2, $fn=20);
219   }
220 }
221
222 module HolesScope(){
223   intersection_for (dx=[-1,+1]) {
224     intersection_for (dy=[-1,+1]) {
225       translate([dx * holeedge, dy * holeedge, -1])
226         scale([1,1,2])
227         CoverTemplate();
228     }
229   }
230 }
231
232 module Holes(){
233   intersection(){
234     translate([holeoffx * holepitch, holeoffy * holepitch, 0]) {
235       for (i=[-10:10]) {
236         translate([i * sqrt(3) * holepitch, 0, 0]) {
237           HoleRow();
238           translate([sqrt(3)/2 * holepitch, -0.5 * holepitch, 0])
239             HoleRow();
240         }
241       }
242     }
243     HolesScope();
244   }
245 }
246
247 module CoverCover(){
248   difference(){
249     CoverTemplate();
250     Holes();
251   }
252 }
253
254 module Cover(){
255   difference(){
256     union(){
257       CoverCover();
258       AtSides() { CoverSide(covershortlen); CoverSide(coverlonglen); }
259     }
260     AtSides() { CoverPegSlot(); CoverPegSlot(); }
261   }
262 }
263
264 module CoverAligned(){
265   translate([0,-front,-height])
266     rotate([-90,0,0])
267     Cover();
268 }
269
270 module DemoPeg(){
271   translate([recessblockwidth/2, pegrecess, -height])
272     Peg();
273 }
274
275 module Demo(){ ////toplevel
276   %Block();
277   DoKnives();
278   color([0,0,1]) CoverAligned();
279   color([1,0,0]) AtSides() { DemoPeg(); DemoPeg(); }
280 }
281
282 module CoverParts(){ ////toplevel
283   Cover();
284   translate([0, coverlonglen, pegheight/2]) {
285     Peg();
286     translate([-peghead-3, 0,0]) Peg();
287   }
288 }
289
290 //Block();
291 //Demo();
292 //Cover();
293 //CoverParts();
294 //Peg();
295 //Cover();