/* MainFrame */ { echo("********** MainFrame **********"); rodSeparation = 45; rodOffset = -10; bar = [5,8]; // thickness, width bearingHolderHoleSeparation = [18,24]; frameWidth = 50; // frameHeight = bearingHolderHoleSeparation[1] + rodSeparation + bar[1]; hole = [4,35,bar[0]*2]; // diameter, length with bearing, length with bar barHoleSeparation = frameWidth - bar[1]; difference() { union() { drawBearingSupports(rodOffset, rodSeparation); drawFrame(bearingHolderHoleSeparation, rodSeparation, bar, frameWidth); } drawHoles(); }; drawSpacers(bar); step = [2*bar[0],bar[0]]; drawStep(step); } module drawHoles() { drawBearingHolderHoles(hole, bearingHolderHoleSeparation, rodSeparation, barHoleSeparation); drawExtraHoles(hole, bearingHolderHoleSeparation, barHoleSeparation); } module drawStep(step) { translate([-frameWidth/2, 0, -frameHeight/2-step[1]]) color("green") cube([frameWidth, step[0], step[1]]); } module drawFrame(bearingHolderHoleSeparation, rodSeparation, bar, frameWidth) { barWidth = frameWidth - 2 * bar[1]; // 4 horizontal bars for(z1=[-1,1]) { for(z2=[-1,1]) { barSeparation = z1*bearingHolderHoleSeparation[1]/2 + z2*rodSeparation/2 - bar[1]/2; translate([-barWidth/2, 0, barSeparation]) color("red") cube([barWidth, bar[0], bar[1]]); } } // 2 widest vertical bars for(z1=[-1,1]) { barSeparation = z1*frameWidth/2 - (z1+1)*bar[1]/2; translate([barSeparation, 0, -frameHeight/2]) color("magenta") cube([bar[1], bar[0], frameHeight]); } // 2 vertical bars over holes for(z1=[-1,1]) { barSeparation = z1*bearingHolderHoleSeparation[0]/2 - bar[1]/2; translate([barSeparation, 0, -frameHeight/2]) color("orange") cube([bar[1], bar[0], frameHeight]); } } module drawBearingHolderHoles(hole, bearingHolderHoleSeparation, bearingHolderSeparation, barHoleSeparation) { for(z=[-1,1]) { for(y=[-1,1]) { hole1 = [hole[0], hole[1]]; for(x=[-1,1]) { translate([x*bearingHolderHoleSeparation[0]/2, -hole[2], z*bearingHolderHoleSeparation[1]/2]) rotate(a=[0,0,90]) drawCylinder("blue", hole1, 0, y*rodSeparation/2); } hole2 = [hole[0], hole[2]]; for(x=[-1,0,1]) { translate([x*barHoleSeparation/2, hole[2]*0.25, z*bearingHolderHoleSeparation[1]/2]) rotate(a=[0,0,90]) drawCylinder("yellow", hole2, 0, y*rodSeparation/2); } } } } module drawExtraHoles(hole, bearingHolderHoleSeparation, barHoleSeparation) { hole1 = [hole[0], hole[2]]; x1 = bearingHolderHoleSeparation[0]/2; x2 = barHoleSeparation/2; for(x=[-x2,-x1,x1,x2]) { translate([x, hole[2]*0.25, 0]) rotate(a=[0,0,90]) drawCylinder("cyan", hole1, 0, 0); } for(z=[-1/3,1/3]) { for(y=[-1,1]) { hole2 = [hole[0], hole[2]]; for(x=[-1,1]) { translate([x*barHoleSeparation/2, hole[2]*0.25, z*bearingHolderHoleSeparation[1]/2]) rotate(a=[0,0,90]) drawCylinder("white", hole2, 0, y*rodSeparation/2); } } } } module drawSpacers(bar) { for(z=[-1,1]) { hole1 = [hole[0], hole[1]]; for(x=[-1,1]) { blockSeparator = x*bearingHolderHoleSeparation[0]/2+bar[1]/2; translate([blockSeparator, hole[2]/2, z*rodSeparation/2-bar[1]/2]) rotate(a=[0,0,90]) color("cyan") cube([bar[0], bar[1], bar[1]]); } } } module drawBearingSupports(rodOffset, rodSeparation) { rod = [8,80]; // diameter, length bearing = [15,45]; // diameter, length bearingHolder = [30,-rodOffset*2,34]; // width, depth, height for(z=[-1,1]) { drawCylinder("grey", rod, rodOffset, z*rodSeparation/2); drawCylinder("black", bearing, rodOffset, z*rodSeparation/2); drawBearingHolder(rodOffset, z*rodSeparation/2, bearingHolder); } } module drawCylinder(cylColor, cylinder, offsetY, offsetZ) { color(cylColor) translate([-cylinder[1]/2, offsetY, offsetZ]) rotate(a=[0,90,0]) cylinder(r=cylinder[0]/2, h=cylinder[1], $fn=16); } module drawBearingHolder(rodY, rodZ, bearingHolder) { // shift to frame centre color("silver") translate([-bearingHolder[0]/2, rodY-bearingHolder[1]/2, rodZ-bearingHolder[2]/2]) cube([bearingHolder[0],bearingHolder[1], bearingHolder[2]]); }