4 module belt(len, side = 0){
5 //belt. To be substracted from model
6 //len is in +Z, smooth side in +X, Y centered
7 translate([-0.5, 0, 0]) maketeeth(len);
8 translate([0, -4.5, -0.01]) cube([belt_thickness, 9, len + 0.02]);
10 translate([0, -4.5 + side, -0.01]) cube_fillet([belt_thickness, 9, len + 0.02], vertical = [3, 0, 0, 0]);
14 module maketeeth(len){
16 for (i = [0 : len / belt_tooth_distance]) {
17 translate([0, 0, i * belt_tooth_distance]) cube([2, 9, belt_tooth_distance * belt_tooth_ratio], center = true);
20 module plate_screw(long=0) {
21 translate([0, 0, -long]) screw(head_drop=14 + long, h=30 + long, r_head=3.6, r=1.7, $fn=24, slant=false);
23 module screw(h=20, r=2, r_head=3.5, head_drop=0, slant=0, poly=false, $fn=0){
24 //makes screw with head
25 //for substraction as screw hole
27 cylinder_poly(h=h, r=r, $fn=$fn);
29 cylinder(h=h, r=r, $fn=$fn);
32 translate([0, 0, head_drop-0.01]) cylinder(h=r_head, r2=0, r1=r_head, $fn=$fn);
36 translate([0, 0, -0.01]) cylinder(h=head_drop+0.01, r=r_head, $fn=$fn);
39 module nut(d,h,horizontal=true){
40 cornerdiameter = (d / 2) / cos (180 / 6);
41 cylinder(h = h, r = cornerdiameter, $fn = 6);
44 rotate([0,0,60*i]) translate([-cornerdiameter-0.2,0,0]) rotate([0,0,-45]) cube([2,2,h]);
49 module fillet(radius, height=100, $fn=0) {
50 //this creates acutal fillet
51 translate([-radius, -radius, -height / 2 - 0.02]) difference() {
52 cube([radius * 2, radius * 2, height + 0.04]);
53 if ($fn == 0 && (radius == 2 || radius == 3 || radius == 4)) {
54 cylinder(r=radius, h=height + 0.04, $fn=4 * radius);
56 cylinder(r=radius, h=height + 0.04, $fn=$fn);
62 module cube_fillet(size, radius=-1, vertical=[3,3,3,3], top=[0,0,0,0], bottom=[0,0,0,0], center=false, $fn=0){
64 if (use_fillets == 1) {
66 cube_fillet_inside(size, radius, vertical, top, bottom, $fn);
68 translate([size[0]/2, size[1]/2, size[2]/2])
69 cube_fillet_inside(size, radius, vertical, top, bottom, $fn);
72 if (use_fillets == 2) {
74 cube_fillet_inside(size, radius, vertical, top, bottom, 4);
76 translate([size[0]/2, size[1]/2, size[2]/2])
77 cube_fillet_inside(size, radius, vertical, top, bottom, 4);
87 module cube_negative_fillet(size, radius=-1, vertical=[3,3,3,3], top=[0,0,0,0], bottom=[0,0,0,0], $fn=0){
93 rotate([0, 0, 90*i]) translate([size[1-j[i]]/2, size[j[i]]/2, 0]) fillet(radius, size[2], $fn=$fn);
95 rotate([0, 0, 90*i]) translate([size[1-j[i]]/2, size[j[i]]/2, 0]) fillet(vertical[i], size[2], $fn=$fn);
97 rotate([90*i, -90, 0]) translate([size[2]/2, size[j[i]]/2, 0 ]) fillet(top[i], size[1-j[i]], $fn=$fn);
98 rotate([90*(4-i), 90, 0]) translate([size[2]/2, size[j[i]]/2, 0]) fillet(bottom[i], size[1-j[i]], $fn=$fn);
103 module cube_fillet_inside(size, radius=-1, vertical=[3,3,3,3], top=[0,0,0,0], bottom=[0,0,0,0], $fn=0){
104 //makes CENTERED cube with round corners
105 // if you give it radius, it will fillet vertical corners.
106 //othervise use vertical, top, bottom arrays
107 //when viewed from top, it starts in upper right corner (+x,+y quadrant) , goes counterclockwise
108 //top/bottom fillet starts in direction of Y axis and goes CCW too
112 cube(size, center=true);
115 cube(size, center=true);
116 cube_negative_fillet(size, radius, vertical, top, bottom, $fn);