chiark / gitweb /
wall-cable-hook: remove hole
[reprap-play.git] / brompton-computer-guard.scad
1 // -*- C -*-
2
3 cover_ysz = 45;
4 cover_len = 70;
5
6 tube_dia = 21;
7
8 attach_cx = -7;
9 attach_cdy = 0;
10 attach_w = 25;
11
12 attach_inrad = 29;
13 attach_hole_dist = 5;
14 attach_hole_dia = 4 + 0.5;
15 attach_ang = 45;
16
17 attach_dz = 2;
18
19 comp_dx = 22;
20 comp_xsz = 45;
21 comp_zsz = 28;
22
23 comp_dy = 5;
24
25 comp_slope = 60;
26
27 leftend_zsz = 10;
28 leftend_dz = comp_zsz * 0.6;
29
30 min_thick = 4;
31
32 rightend_thick = 10;
33 bolthead_space = 4;
34
35 // calculated
36
37 cover_lcircle_r = cover_ysz / (1 + 1/sqrt(2));
38
39 base_len = cover_len - cover_lcircle_r;
40
41 attach_end_r = attach_w/2;
42
43 attach_straight_len =
44   attach_inrad + tube_dia + attach_hole_dist + attach_hole_dia/2
45   - attach_end_r + attach_hole_dist;
46
47 attach_down = tube_dia/2 + attach_dz;
48
49 attach_xmax = attach_cx +
50   cos(attach_ang) * attach_straight_len + attach_end_r;
51
52 module RearSideTemplate(){
53   polygon([[0.1,0],
54            [-base_len,0],
55            [-base_len,-cover_ysz],
56            [0.1,      -cover_ysz]]);
57   translate([-base_len, -cover_ysz + cover_lcircle_r])
58     circle(r=cover_lcircle_r);
59 }
60
61 module AttachTemplate(){
62   hull(){
63     polygon([[0,   0],
64              [-0.1, 0],
65              [-0.1, -cover_ysz],
66              [0,    -cover_ysz]]);
67     translate([attach_cx, -attach_cdy]) rotate([0,0,-attach_ang]) {
68       polygon([[-attach_cx,          attach_w/2],
69                [0,                   -attach_w/2],
70                [attach_straight_len, -attach_w/2],
71                [attach_straight_len, attach_w/2]]);
72       translate([attach_straight_len, 0])
73         circle(r=attach_end_r);
74     }
75   }
76 }
77
78 module AttachElevation(anddown){
79   hull(){
80     translate([-cover_len - 0.5, leftend_dz - leftend_zsz/2])
81       square([1, leftend_zsz]);
82     translate([-comp_dx - comp_xsz/2, -0.1])
83       square([comp_xsz, comp_zsz + min_thick]);
84     translate([attach_xmax, 0])
85       square([1, rightend_thick + bolthead_space]);
86   }
87   if (anddown)
88     translate([-comp_dx, -attach_down-5])
89       square([comp_dx + attach_xmax+2, attach_down+6]);
90 }
91
92 module AttachElevationSelector(anddown) {
93   translate([0,100,0]) rotate([90,0,0]) linear_extrude(height=200)
94     AttachElevation(anddown);
95 }
96
97 module BodyPositive(){
98   intersection(){
99     linear_extrude(height=60) RearSideTemplate();
100     AttachElevationSelector(false);
101   }
102   intersection(){
103     translate([0,0,-attach_down]) linear_extrude(height=100) AttachTemplate();
104     AttachElevationSelector(true);
105   }
106 }
107
108 module Cutouts(){
109   Tube();
110   Bolts();
111   Computer();
112 }
113
114 module Body(){
115   difference(){
116     intersection(){
117       BodyPositive();
118       translate([-100,-200,-100]) cube([200,200,200]);
119     }
120     Cutouts();
121   }
122 }
123
124 module Computer(){
125   multmatrix([[1,0,0,0],
126               [0,1, tan(90-comp_slope), 0],
127               [0,0,1,0],
128               [0,0,0,1]])             
129   translate([-comp_dx - comp_xsz/2, -cover_ysz + comp_dy, -50])
130     cube([comp_xsz, 100, comp_zsz + 50]);
131 }
132
133 module Tube(){
134   translate([attach_cx, -attach_cdy, -tube_dia/2 - 0.1 - attach_dz]) {
135     rotate_extrude(convexity=10) {
136       translate([attach_inrad + tube_dia/2, 0])
137         circle(r=tube_dia/2);
138     }
139   }
140 }
141
142 module Bolt(){
143   translate([0,0,-50]) linear_extrude(height=80) {
144     circle(r=attach_hole_dia/2, $fn=20);
145   }
146   translate([0,0,rightend_thick]) linear_extrude(height=80) {
147     circle(r=attach_hole_dia/2 * 2, $fn=20);
148   }
149 }
150
151 module Bolts(){
152   translate([attach_cx, -attach_cdy]) rotate([0,0,-attach_ang]) {
153     translate([attach_inrad - attach_hole_dist - attach_hole_dia/2, 0])
154       Bolt();
155     translate([attach_inrad + tube_dia
156                +attach_hole_dist + attach_hole_dia/2, 0])
157       Bolt();
158   }
159 }
160
161 module Demo(){
162   Cutouts();
163   %BodyPositive();
164 }
165
166 module Print(){
167   rotate([-90,00])
168     Body();
169 }
170
171 //Demo();
172 //Body();
173 Print();