chiark / gitweb /
knifeblock: peg
[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 pegstem = 3.5;
40 peghead = 10;
41 pegstemheight = 2;
42 pegheight = 9;
43 peglen = 12;
44
45 pegslop = 0.5;
46
47 // computed
48 side = minsidein + screwcsinkdia + minsideout;
49 totaldepth = front + maxhandledepth + back;
50
51 minkx = locations[0] -         widths[0]        /2;
52 maxkx = locations[nknives-1] + widths[nknives-1]/2;
53
54 minx = minkx - side;
55 maxx = maxkx + side;
56
57 module ImportTemplate(w,k,t) {
58   fn = str("knifeblock-knives-t",k,t,".dxf");
59   echo(fn);
60   translate([0,0, -w/2])
61     linear_extrude(height=w)
62     scale(templatescale) import(file=fn, convexity=100);
63 }
64
65 module Knife(k){
66   ImportTemplate(bladew, k,"bl");
67   hull(){
68     ImportTemplate(widths[k], k,"hl");
69     translate([-100,0,0])
70       ImportTemplate(widths[k], k,"hl");
71   }
72 }
73
74 module DoKnife(k){
75   translate([locations[k],0,0]){
76     rotate([0,90,0])
77       translate([-(handlelenbase + handlelendelta[k]),0,0])
78       Knife(k);
79   }
80 }
81
82 module DoKnives(){
83   for (k=[0:nknives-1])
84     DoKnife(k);
85 }
86
87 module ScrewHole(){
88   translate([0,-50,0])
89     rotate([-90,0,0])
90     cylinder(r=screwdia/2, h=150, $fn=40);
91   translate([0, totaldepth-front - screwbackdepth, 0])
92     rotate([90,0,0])
93     cylinder(r=screwcsinkdia/2 / (sqrt(3)/2), h=100, $fn=6);
94 }
95
96 module Block(){
97   sidemidx = minsideout + screwcsinkdia/2;
98
99   difference(){
100     hull() mirror([0,0,1]) {
101       translate([minx, 0, 0])
102         cube([maxx-minx, totaldepth-front, height]);
103       for (x=[minx + front/2, maxx - front/2])
104         translate([x, -front/2, 0])
105         cylinder(r=front/2, h=height, $fn=30);
106     }
107     for (x=[minx + sidemidx, maxx - sidemidx]) {
108       translate([x, 0, -screwabove])
109         ScrewHole();
110     }
111     for (yshift=[-1,1])
112       translate([0, yshift * frontbackslop, 0])
113         DoKnives();
114   }
115 }
116
117 module BlockPrint(){ ////toplevel
118   rotate([0,0,90])
119     Block();
120 }
121
122 module CoverTemplate(){
123   linear_extrude(height=coverthick)
124     polygon([[minx, 0],
125              [maxx, 0],
126              [maxx, coverlonglen],
127              [maxx - coverside, coverlonglen],
128              [minx, covershortlen]]);
129 }
130
131 module CoverSide(xpos, len){
132   translate([xpos, 0 ,0]) {
133     rotate([90,0,90])
134       linear_extrude(height=coverside)
135       polygon([[0,                      0],
136                [0,                      totaldepth],
137                [covertopwing,           totaldepth],
138                [covertopwingbase,       coverside + coverthick],
139                [len - covertopwingbase, coverside + coverthick],
140                [len - covertopwing,     totaldepth],
141                [len,                    totaldepth],
142                [len,                    0]]);
143   }
144 }
145
146 module PegTemplate(){
147   for (mx=[0,1]) for (my=[0,1]) {
148       mirror([mx,0,0]) mirror([0,my,0])
149         polygon([[-0.1,      -0.1],
150                  [pegstem/2, -0.1],
151                  [pegstem/2, pegstemheight/2],
152                  [peghead/2, pegheight    /2],
153                  [-0.1,      pegheight    /2]]);
154     }
155 }
156
157 module Peg(){
158   echo("peg angle slope (must be <1)",
159        (peghead-pegstem)/(pegheight-pegstemheight));
160   d = pegslop;
161   rotate([90,0,0]) {
162     linear_extrude(height=peglen) {
163       intersection(){
164         translate([-d,-d,0]) PegTemplate();
165         translate([-d,+d,0]) PegTemplate();
166         translate([+d,+d,0]) PegTemplate();
167         translate([+d,-d,0]) PegTemplate();
168       }
169     }
170   }
171 }
172
173 module Cover(){
174   CoverTemplate();
175   CoverSide(minx,           covershortlen);
176   mirror([1,0,0]) CoverSide(-maxx, coverlonglen);
177 }
178
179 module CoverAligned(){
180   translate([0,-front,-height])
181     rotate([-90,0,0])
182     Cover();
183 }
184
185 module Demo(){ ////toplevel
186   %Block();
187   DoKnives();
188   color([0,0,1]) CoverAligned();
189 }
190
191 Demo();
192 //Cover();