Made into functions
[cad-files.git] / rackable / 19to22adapter / 19to22adapter.escad
1 // 19 to 22 inch rack adapter
2
3 // Change these to adjust the total adapter size
4 full_length = 80;
5 full_width = 44.23;
6 full_height = 45;
7
8 // Change these to adjust the interface to your device
9 support_bracket_thickness = 10;
10 support_bracket_base_thickness = 2.5;
11 support_bracket_hole_y_offset = 18;
12 support_bracket_hole_z_offset = 18;
13 support_bracket_hole_r = 2;
14
15 // Change these to adjust the interface to your rack (should be standard)
16 rack_mount_length = 20;
17 rack_mount_thickness = 2.5;
18 rack_mount_hole_r = 6.5 / 2;
19 rack_mount_hole_x_offset = (11.75 / 2) + 5.3;
20 rack_mount_hole_y_offset = rack_mount_hole_r + 2.9;
21
22 // Add two triangle supports that end at the start of the interface to the rack.
23 module dual_supports(length, width, height, support_length, support_thickness, support_base_thickness) {
24 difference() { // Extra triangle supports on both sides of the Y axis
25 translate([support_base_thickness, 0, 0])
26 linear_extrude(height(x, y) = (-width / support_length) * x + width) square(size = [support_length, width]);
27 translate([support_base_thickness, support_thickness, 0])
28 linear_extrude(height) square(size = [support_length, width - support_thickness * 2]);
29 }
30 }
31
32 // Create our basic L-shaped bracket
33 module l_bracket(length, width, height, rack_thickness, support_base_thickness) {
34 difference() { // Cut our L bracket
35 linear_extrude(height) square(size = [length, width]);
36
37 translate([0,0, rack_thickness])
38 linear_extrude(height)
39 translate([support_base_thickness, 0]) square(size = [length, width]);
40 }
41 }
42
43 // Cuts the bolt holes for attachingto the rack
44 module rack_bolt_holes(height, x_offset, y_offset, rack_hole_r) {
45 // Holes for rackmount
46 translate([x_offset, y_offset, 0])
47 linear_extrude(height) circle(r = rack_hole_r);
48 }
49
50 module support_screw_hole(height, y_offset, z_offset, support_hole_r) {
51 translate([-1, y_offset, z_offset]) rotate(a = [0, 90])
52 linear_extrude(height) circle(r = support_hole_r);
53 }
54
55 // Builds the full object
56 module rack_adapter(length, width, height, rack_length, rack_thickness, rack_hole_r, rack_hole_x_offset, rack_hole_y_offset, support_thickness, support_base_thickness, support_hole_y_offset, support_hole_z_offset, support_hole_r) {
57
58 support_length = length - rack_length;
59
60 difference() { // For adding the screw holes
61
62 union(r = 0) { // Combine supports with L bracket
63 dual_supports(length, width, height, support_length, support_thickness, support_base_thickness);
64 l_bracket(length, width, height, rack_thickness, support_base_thickness);
65 }
66
67 // Holes for rackmount
68 rack_bolt_holes(height, rack_hole_x_offset + support_length, width - rack_hole_y_offset, rack_hole_r);
69 rack_bolt_holes(height, rack_hole_x_offset + support_length, rack_hole_y_offset, rack_hole_r);
70
71 // Holes for mounting to unit
72
73 support_screw_hole(height, support_hole_y_offset, support_hole_z_offset, support_hole_r);
74 support_screw_hole(height, width - support_hole_y_offset, support_hole_z_offset, support_hole_r);
75 support_screw_hole(height, support_hole_y_offset, height - support_hole_z_offset, support_hole_r);
76 support_screw_hole(height, width - support_hole_y_offset, height - support_hole_z_offset, support_hole_r);
77 }
78 }
79
80 // Call the main construct
81 rack_adapter(full_length, full_width, full_height, rack_mount_length, rack_mount_thickness, rack_mount_hole_r, rack_mount_hole_x_offset, rack_mount_hole_y_offset, support_bracket_thickness, support_bracket_base_thickness, support_bracket_hole_y_offset, support_bracket_hole_z_offset, support_bracket_hole_r);
82