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