separate data into *-data.scad for 3d models
[challenge-bot] / 3d-printables / deck-data.scad
1 // challenge-bot
2 // GNU AGPLv3 (or later at your option)
3 // project available at these locations:
4 // https://gitorious.org/ozzloy/challenge-bot
5 // https://github.com/waynegramlich/challenge-bot
6
7 // all measurements are in mm unless stated otherwise
8
9 // metric version of deck:
10 deck_length = 250;
11 deck_width = deck_length;
12 deck_depth = 5;
13 deck_pitch = 10;
14 deck_grid_hole = 3;
15 deck_hole_type = "square";
16 deck_centered = true;
17
18 /*
19 // imperial version of deck
20 deck_length = 203.2; // 8 inches
21 deck_width = deck_length;
22 deck_depth = 25.4 * 3 / 16; // 3 / 16 of an inch
23 deck_pitch = 25.4; // 1 inch
24 deck_grid_hole = 6.35 / 2; // 1/4 inch diameter, 1/8 inch radius
25 deck_hole_type = "circle";
26 */
27
28 module deck_2d(width, length, pitch, hole, hole_type, center = false) {
29 center_width_offset = center ? -(width / 2) : 0;
30 center_length_offset = center ? -(length / 2) : 0;
31 translate([center_width_offset, center_length_offset]) {
32 difference() {
33 square([width, length]);
34 for (y = [0:floor(length / pitch) - 1],
35 x = [0:floor(width / pitch) - 1]) {
36 translate([pitch * (x + 0.5), pitch * (y + 0.5)]) {
37 if (hole_type == "circle") {
38 circle(hole, center = true); }
39 else if (hole_type == "square") {
40 square(hole, center = true); }
41 else {
42 echo(str("don't know the hole type: ", hole_type)); } } } } } }
43
44 module deck(width, length, depth, pitch, hole, hole_type, center = false) {
45 linear_extrude(height = depth) {
46 deck_2d(width, length, pitch, hole, hole_type, center); } }