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