CascadeStudio_3D_Manual
98 строк · 3.3 Кб
1// test
2function lever(r1, r2, d, h, t)3{
4// This function creates a lever between two bearings,
5// the axles of the bearings are aligned
6
7// r1 = radius larger bearing
8// r2 = radois smaller bearing
9// d = distance between two bearings
10// h = height or width of the lever
11// t = wallthickness around bearing and cutout
12
13let sinus_a = (r1 - r2) / d ;14let a = Math.asin(sinus_a);15
16// points of outer contour of the lever17let p1 = [r1 * Math.sin(a), r1 * Math.cos(a)];18let p2 = [d + r2 * Math.sin(a), r2 * Math.cos(a)];19let p3 = [d + r2, 0];20let p4 = [d + r2 * Math.sin(a), - r2 * Math.cos(a)];21let p5 = [r1 * Math.sin(a), - r1 * Math.cos(a)];22let p6 = [- r1, 0 ];23
24// points of cutout of the lever (not used as cutout became too small)25let c1 = [(r1-t) * Math.sin(a), (r1-t) * Math.cos(a)];26let c2 = [d + (r2-t) * Math.sin(a), (r2-t) * Math.cos(a)]; ;27let c3 = [d - r2 + t , 0];28let c4 = [d + (r2-t) * Math.sin(a), - (r2-t) * Math.cos(a)];29let c5 = [(r1-t) * Math.sin(a), - (r1-t) * Math.cos(a)];30let c6 = [r1-t,0];31
32let sketchLever = new Sketch(p1).33LineTo(p2).34ArcTo(p3,p4).35LineTo(p5).36ArcTo(p6,p1).37End(false).Face(true);38
39let leverbody = Extrude(sketchLever,[0,0,h]);40
41let big_hole = Cylinder((r1-t), 2* (h + 10), true);42let small_hole = Translate([d, 0,0 ], Cylinder((r2-t), 2* (h + 10), true));43let rough_lever = Difference(leverbody,[big_hole, small_hole]);44
45let cutout = new Sketch(p1).46LineTo(p2).47ArcTo(c3,p4).48LineTo(p5).49ArcTo(c6,p1).50End(false).Face(true);51
52let cutoutbody = Extrude(cutout,[0,0,h+10]);53let cutoutsmaller = Offset(cutoutbody, (-1.5 * t));54
55// ALTERNATIVE APPROACH FOR FILLETING56// make shrunk version of cutout a bit smaller and then offset it again with57// the filletradius58let cutoutbigger = Offset(cutoutsmaller, (0.5 * t));59let cutoutround = cutoutbigger;60let cutout_top = Translate([0,0,(h + t)/2],cutoutround);61let cutout_bot = Translate([0,0,(-h - t)/2 -10],cutoutround);62
63let rough_lever2 = Difference(rough_lever, [cutout_top, cutout_bot]);64return rough_lever2;65}
66
67
68function sideviewblock(r1, r2, d, h, t)69{
70// r1 = radius larger bearing
71// r2 = radois smaller bearing
72// d = distance between two bearings
73// h = height or width of the lever
74// t = wallthickness around bearing and cutout
75
76let sideview = new Sketch( [-r1-1,0] )77.LineTo([-r1-1,0.5*h])78.LineTo([r1,0.5*h])79.LineTo([d-r2,(0.1*h)+(1.2*t)])80.LineTo([d+r2,(0.1*h)+(1.2*t)])81.LineTo([d+r2,(-0.1*h)-(1.2*t)])82.LineTo([d-r2,(-0.1*h)-(1.2*t)])83.LineTo([r1,-0.5*h])84.LineTo([-r1-1,-0.5*h])85.LineTo([-r1-1,0])86.End(false,false).Face();87
88let block = Extrude(sideview, [0,0,(2*r1)+(2*t)]);89
90let side1 = Rotate([1,0,0],90,block);91let side2 = Translate([0, r1+1,0.5*h],side1);92
93return side2;94}
95
96let sidecut = sideviewblock(30,10,100,40,2);97let levershape = lever(30,10,100,40,2);98Intersection([levershape,sidecut]);99
100