jug-counter/openscad/bot.scad
2023-03-08 22:45:09 +02:00

122 lines
2.8 KiB
OpenSCAD

size_wall = 1.5;
size_floor = size_wall * 3;
size_x = 105;
size_y = 50;
size_z = 7;
hole_dist_x = 35;
hole_dist_y = 20.5;
hole_rad = 3 / 2;
slide_x = 30;
slide_y = 35;
module blind_hole(r_top = 1.5, r_bot = 3, z_size = 3, seg = 60)
{
h = r_bot > r_top ? r_bot - r_top : r_top - r_bot;
union()
{
// Big/small
cylinder(h, r_bot, r_top, $fn = seg, center = true);
translate([0, 0, h/2 + (z_size - h)/4])
cylinder((z_size - h)/2, r_top, r_top, $fn = seg, center = true);
translate([0, 0, -h/2 - (z_size - h)/4])
cylinder((z_size - h)/2, r_bot, r_bot, $fn = seg, center = true);
}
}
module slide_box_top_y(x, y, lip)
{
difference()
{
cube([x, y, lip * 3], center = true);
cube([x - lip * 4, y - lip * 4, lip * 3 + 1], center = true);
translate([0, -(y / 2 - lip), lip])
{
cube([x - lip * 4, lip * 2 + 1, lip * 3], center = true);
}
for (x_dir = [-1:2:1])
{
//translate([(x - lip * 4) / 2 * x_dir, -lip * 2, lip / 2])
translate([(x - lip * 4) / 2 * x_dir, -lip * 2, lip / 2])
rotate([-90, 0, 0])
linear_extrude(y, center = true)
{
polygon([[0, 0], [0, lip], [lip * x_dir, lip]]);
}
}
}
}
difference()
{
union()
{
difference()
{
// Main block
cube([size_x + size_wall * 2 + 1, size_y + size_wall * 2 + 1, size_z + size_floor], center = true);
// Hollow
translate([0, 0, size_floor])
{
cube([size_x + 1, size_y + 1, size_z + size_floor], center = true);
}
// Cut slide cover
translate([-slide_x/2 + (size_x + size_wall * 2 + 1) / 2, -slide_y/2 + (size_y + size_wall * 2 + 1) / 2, size_floor/2 - (size_z + size_floor) / 2])
{
cube([slide_x, slide_y, size_floor], center = true);
}
}
// Mounts
for (x = [-1:2:1])
{
for (y = [-1:2:1])
{
translate([x * hole_dist_x, y * hole_dist_y, 0])
{
difference()
{
cylinder(size_z + size_floor - 2, hole_rad + size_wall, hole_rad + size_wall, $fn = 60, center = true);
cylinder(size_z + size_floor + 1, hole_rad, hole_rad, $fn = 60, center = true);
}
}
}
}
// Add slide cover
translate([-slide_x/2 + (size_x + size_wall * 2 + 1) / 2, -slide_y/2 + (size_y + size_wall * 2 + 1) / 2, size_wall * 3 / 2 - (size_z + size_floor) / 2])
rotate([180, 0, -90])
{
slide_box_top_y(x = slide_y, y = slide_x, lip = size_wall);
}
}
// Cut screw holes
for (x = [-1:2:1])
{
for (y = [-1:2:1])
{
translate([x * hole_dist_x, y * hole_dist_y, size_floor/2 - (size_z + size_floor)/2])
{
blind_hole(r_top = hole_rad, r_bot = hole_rad * 2, z_size = size_floor);
}
}
}
// Cut bit of lip and extra screw
translate([-slide_x/2 + size_wall/2 + (size_x + size_wall * 2 + 1) / 2, -slide_y/2 + (size_y + size_wall * 2 + 1) / 2, 0])
{
cube([slide_x - size_wall * 3, slide_y - size_wall * 4, size_z + size_floor + 1], center = true);
}
}