2012-03-12 01:13:07 +00:00
|
|
|
//
|
|
|
|
// Mendel90
|
|
|
|
//
|
|
|
|
// GNU GPL v2
|
|
|
|
// nop.head@gmail.com
|
|
|
|
// hydraraptor.blogspot.com
|
|
|
|
//
|
|
|
|
// Utilities
|
|
|
|
//
|
|
|
|
include <../utils/bom.scad>
|
|
|
|
include <../utils/polyholes.scad>
|
|
|
|
include <../utils/teardrops.scad>
|
|
|
|
include <../utils/cables.scad>
|
2012-11-15 17:45:30 +00:00
|
|
|
include <../utils/shields.scad>
|
2012-03-12 01:13:07 +00:00
|
|
|
|
2016-01-06 00:49:11 +00:00
|
|
|
function round_to_layer(z) = ceil(z / layer_height) * layer_height;
|
|
|
|
|
2012-03-12 01:13:07 +00:00
|
|
|
module slot(h, r, l, center = true)
|
|
|
|
linear_extrude(height = h, convexity = 6, center = center)
|
|
|
|
hull() {
|
|
|
|
translate([l/2,0,0])
|
2016-01-06 00:49:11 +00:00
|
|
|
circle(r);
|
2012-03-12 01:13:07 +00:00
|
|
|
translate([-l/2,0,0])
|
2016-01-06 00:49:11 +00:00
|
|
|
circle(r);
|
2012-03-12 01:13:07 +00:00
|
|
|
}
|
|
|
|
|
2016-01-06 00:49:11 +00:00
|
|
|
module hole_support(r, h, max_r = 999, closed = false, capped = false) {
|
2013-09-25 01:28:24 +01:00
|
|
|
n = sides(r);
|
|
|
|
cr = corrected_radius(r, n);
|
|
|
|
ir = min(cr, max_r - 2.25 * filament_width);
|
|
|
|
or = ir + 2 * filament_width;
|
|
|
|
difference() {
|
|
|
|
cylinder(r = or, h = h, $fn = n);
|
2016-01-06 00:49:11 +00:00
|
|
|
difference() {
|
|
|
|
translate([0, 0, closed ? layer_height : -1])
|
|
|
|
cylinder(r = ir, h = h + 2, $fn = n);
|
|
|
|
|
|
|
|
if(capped)
|
|
|
|
translate([0, 0, h - 4 * layer_height])
|
|
|
|
cylinder(r = or, h = 3 * layer_height + eta);
|
|
|
|
}
|
2013-09-25 01:28:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module nut_trap_support(h, r, r2 = 0) {
|
|
|
|
ir = r;
|
|
|
|
ir2 = r2 ? r2 : r;
|
|
|
|
or = ir + 2 * filament_width;
|
|
|
|
or2 = ir2 + 2 * filament_width;
|
|
|
|
difference() {
|
|
|
|
cylinder(r2 = or, r1 = or2, h = h, $fn = 6);
|
|
|
|
translate([0, 0, -1])
|
|
|
|
cylinder(r2 = ir, r1 = or2, h = h + 2, $fn = 6);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-17 10:33:00 +00:00
|
|
|
module part_screw_hole(screw, nut, horizontal = false, supported = false) {
|
|
|
|
screw_r = screw_clearance_radius(screw);
|
|
|
|
if(nut)
|
|
|
|
translate([0, 0, nut_trap_depth(nut)])
|
|
|
|
nut_trap(screw_r, nut_radius(nut), nut_trap_depth(nut), horizontal, supported);
|
|
|
|
else
|
|
|
|
if(horizontal)
|
|
|
|
teardrop_plus(r = screw_r, h = 200, center = true);
|
|
|
|
else
|
|
|
|
poly_cylinder(r = screw_r, h = 200, center = true);
|
|
|
|
}
|
|
|
|
|
2012-03-12 01:13:07 +00:00
|
|
|
module fillet(r, h) {
|
|
|
|
translate([r / 2, r / 2, 0])
|
|
|
|
difference() {
|
|
|
|
cube([r + eta, r + eta, h], center = true);
|
|
|
|
translate([r/2, r/2, 0])
|
|
|
|
cylinder(r = r, h = h + 1, center = true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module right_triangle(width, height, h, center = true) {
|
|
|
|
linear_extrude(height = h, center = center)
|
|
|
|
polygon(points = [[0,0], [width, 0], [0, height]]);
|
|
|
|
}
|
|
|
|
|
|
|
|
module rounded_square(w, h, r)
|
|
|
|
{
|
2016-01-08 18:17:16 +00:00
|
|
|
hull() {
|
2012-03-12 01:13:07 +00:00
|
|
|
square([w - 2 * r, h], center = true);
|
|
|
|
square([w, h - 2 * r], center = true);
|
|
|
|
for(x = [-w/2 + r, w/2 - r])
|
|
|
|
for(y = [-h/2 + r, h/2 - r])
|
|
|
|
translate([x, y])
|
2016-01-06 00:49:11 +00:00
|
|
|
circle(r);
|
2012-03-12 01:13:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module rounded_rectangle(size, r, center = true)
|
|
|
|
{
|
|
|
|
w = size[0];
|
|
|
|
h = size[1];
|
|
|
|
linear_extrude(height = size[2], center = center)
|
|
|
|
rounded_square(size[0], size[1], r);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Cylinder with rounded ends
|
|
|
|
//
|
|
|
|
module rounded_cylinder(r, h, r2)
|
|
|
|
{
|
|
|
|
rotate_extrude()
|
2016-01-06 00:49:11 +00:00
|
|
|
hull() {
|
|
|
|
square([1, h]);
|
|
|
|
square([r, 1]);
|
2012-03-12 01:13:07 +00:00
|
|
|
translate([r - r2, h - r2])
|
2016-01-06 00:49:11 +00:00
|
|
|
intersection() {
|
|
|
|
circle(r2);
|
|
|
|
square(r2);
|
|
|
|
}
|
2012-03-12 01:13:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module sector(r, a, h, , center = true) {
|
|
|
|
linear_extrude(height = h, center = center)
|
|
|
|
intersection() {
|
|
|
|
circle(r = r, center = true);
|
|
|
|
polygon(points = [
|
|
|
|
[0, 0],
|
|
|
|
[2 * r * cos(a / 2), 2 * r * sin(a / 2)],
|
|
|
|
[2 * r * cos(a / 2), -2 * r * sin(a / 2)],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module tube(or, ir, h, center = true) {
|
2012-12-24 13:15:00 +00:00
|
|
|
linear_extrude(height = h, center = center, convexity = 5)
|
|
|
|
difference() {
|
|
|
|
circle(or);
|
|
|
|
circle(ir);
|
|
|
|
}
|
2012-03-12 01:13:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Exploded view helper
|
|
|
|
//
|
|
|
|
module explode(v, offset = [0,0,0]) {
|
|
|
|
if(exploded) {
|
2014-06-12 23:12:59 +01:00
|
|
|
translate(v * exploded)
|
2016-01-06 00:49:11 +00:00
|
|
|
children();
|
2012-03-12 01:13:07 +00:00
|
|
|
render() hull() {
|
|
|
|
sphere(0.2);
|
2014-06-12 23:12:59 +01:00
|
|
|
translate(v * exploded + offset)
|
2012-03-12 01:13:07 +00:00
|
|
|
sphere(0.2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2016-01-06 00:49:11 +00:00
|
|
|
children();
|
2012-03-12 01:13:07 +00:00
|
|
|
}
|