chiark / gitweb /
pattress-boxes-3-cover: Rail, set overlap explicitly
[reprap-play.git] / pattress-boxes-3-cover.scad
1 // -*- C -*-
2
3 patbox_side = 87;
4 patbox_centres = 60.3;
5
6 lid_thinboxbase_overlap = 5;
7 lid_fatbox_overlap = 12;
8
9 lid_thinbox_h = 9;
10 lid_fatbox_h = 24;
11 lid_fatbox_switches_h = 6+2;
12
13 lid_max_switches_w = 70;
14 lid_switches_y_slop = 3;
15
16 total_len = 260;
17 thinbox_len = 87;
18
19 rail_overlap = 8;
20
21 lid_top_wall = 1.5;
22 lid_front_wall = 1.5;
23 lid_side_wall = 1.5;
24
25 peg_engage_depth = 1;
26 peg_engage_dia = 6.5;
27 peg_main_dia = 9;
28 peg_max_dia = 15;
29 peg_inner_dia = 3.5;
30 peg_top_thick = 1;
31 peg_straight_len = 3;
32
33 peg_inner_slop = 0.2;
34 peg_outer_slop = 0.1;
35
36 peg_slope = 1;
37
38 lid_side_slop = 0.5;
39 lid_rail_behindslop = 0.5;
40
41 // computed
42
43 lid_inner_max_h =
44   lid_thinboxbase_overlap + lid_fatbox_h + lid_fatbox_switches_h;
45 lid_inner_min_h = lid_fatbox_overlap + lid_fatbox_switches_h;
46
47 lid_inner_kink = [thinbox_len, thinbox_len*2];
48
49 lid_inner_w_nom = patbox_side;
50 lid_inner_w = lid_inner_w_nom + lid_side_slop * 2;
51
52 lid_seatline_w = (lid_inner_w - lid_max_switches_w)/2 - lid_switches_y_slop;
53
54 lid_seatline_h = lid_fatbox_switches_h;
55
56 echo(lid_seatline_w);
57
58 peg_main_height = peg_straight_len + (peg_max_dia - peg_main_dia)/2/peg_slope;
59
60 echo(peg_main_height);
61
62 thinbox_front_z = lid_fatbox_switches_h + lid_fatbox_h - lid_thinbox_h;
63
64 raillen = patbox_side/2 + rail_overlap;
65
66 module LidSideProfile(){
67   polygon([[-lid_top_wall,     lid_inner_max_h],
68            [lid_inner_kink[0], lid_inner_max_h],
69            [lid_inner_kink[1], lid_inner_min_h],
70            [total_len,         lid_inner_min_h],
71            [total_len,         -lid_front_wall],
72            [-lid_top_wall,     -lid_front_wall]]);
73 }
74
75 module RailProfile(){
76   yt_base = thinbox_front_z;
77   yt = yt_base - lid_rail_behindslop;
78   pegx = (lid_inner_w_nom - patbox_centres)/2;
79   
80   polygon([[-0.1,                  yt],
81            [pegx - peg_main_dia/2, yt],
82            [pegx - peg_main_dia/2, yt_base - peg_straight_len],
83            [-0.1,
84             yt_base - peg_straight_len - (pegx - peg_main_dia/2)/peg_slope
85            -0.1]]);
86 }
87
88 module LidSide(){
89   overlap = [0.1, 0.1, 0.1];
90
91   // main side profile
92   rotate([90,0,0])
93     linear_extrude(height= lid_side_wall)
94     LidSideProfile();
95
96   // seatline
97   translate(-overlap)
98     cube(overlap + [total_len, lid_seatline_w, lid_seatline_h]);
99
100   // lid front
101   translate([-0.1, -0.1, -lid_front_wall])
102     cube([total_len+0.1, lid_inner_w/2 + 0.2, lid_front_wall]);
103
104   // lid top
105   translate([-lid_top_wall, -lid_side_wall, -lid_front_wall])
106     cube([lid_top_wall, lid_inner_w/2 + 10, lid_front_wall + lid_inner_max_h]);
107
108   // rail
109   rotate([90,0,90])
110     translate([0,0,-0.1])
111     linear_extrude(height=raillen+0.1) //todo
112     RailProfile();
113 }
114
115 module PegProfile(){
116   polygon([[-peg_engage_depth, (peg_engage_dia - peg_outer_slop)/2],
117            [0,                 (peg_engage_dia - peg_outer_slop)/2],
118            [0,                 (peg_main_dia - peg_outer_slop)/2],
119            [peg_straight_len,  (peg_main_dia - peg_outer_slop)/2],
120            [peg_main_height,   (peg_max_dia - peg_outer_slop)/2],
121            [peg_main_height+peg_top_thick, (peg_max_dia - peg_outer_slop)/2],
122            [peg_main_height+peg_top_thick, (peg_inner_dia + peg_inner_slop)/2],
123            [-peg_engage_depth,  (peg_inner_dia + peg_inner_slop)/2]]);
124 }
125
126 module Peg(){
127   rotate_extrude($fn=50)
128     rotate([0,0,-90])
129     PegProfile();
130 }
131
132 module AtFixingCentres(){
133   for (fc=[-1,+1]) {
134     translate([patbox_side/2 + fc*patbox_centres/2,
135                patbox_side/2,
136                0])
137       children();
138   }
139 }
140
141 module TopPattressBox(){
142   difference(){
143     translate([0,0, -lid_thinbox_h])
144       cube([patbox_side, patbox_side, lid_thinbox_h]);
145     AtFixingCentres(){
146       translate([0,0,-10]) cylinder(r=peg_engage_dia/2, h=20);
147     }
148   }
149 }
150
151 module Demo(){
152   translate([0, -lid_inner_w/2, 0]) LidSide();
153   translate([0,0, thinbox_front_z])
154     rotate([0,180,0]) translate([0, -patbox_side/2, 0])
155     rotate([0,0,90]) union(){
156       %TopPattressBox();
157       color("blue") AtFixingCentres(){
158         rotate([180,0,0]) Peg();
159       }
160   }
161 }
162
163 //LidSide();
164 //PegProfile();
165 //Peg();
166 //TopPattressBox();
167 //RailProfile();
168 Demo();