openscad-parts/Power_bar_screwdown/power_bar_screwdown.scad
2014-01-21 20:25:28 +01:00

119 lines
2.5 KiB
OpenSCAD

// asdfadsf
radius = product_of_the_triangle_side_lengths / area_of_the_triangle_multiplied_by_4;
FN=80*1;
width_shortest = 40;
width_longest = 60;
height = 40;
wall_thickness = 3;
max_length = 30;
// Gotta do some mathematics
triangle_height = (width_longest - width_shortest) / 2;
triangle_width = height / 2;
slanted_side = sqrt(pow(triangle_height, 2) + pow(triangle_width,2));
product_triangle_sides = slanted_side * slanted_side * height;
triangle_area = (height*triangle_height)/2;
radius_side = product_triangle_sides / (4 * triangle_area);
echo(str("Radius: ", radius_side));
module body(radius_sides, body_height, body_width, inner){
intersection(){
intersection(){
translate([0,0,-body_height/2]){
cube([body_width,100,body_height]);
}
union(){
translate([radius_sides,0,0]){
rotate([-90,0,0]){
cylinder(h=100, r=radius_sides, $fn=FN);
}
}
translate([body_width-radius_sides,0,0]){
rotate([-90,0,0]){
cylinder(h=100, r=radius_sides, $fn=FN);
}
}
}
}
union(){
translate([0,radius_sides,-body_height/2]){
cube([body_width,100,body_height]);
}
if (inner == 1) {
translate([0,radius_sides,0]){
rotate([0,90,0]){
cylinder(h=100, r=radius_sides, $fn=FN);
}
}
} else {
translate([0,0,-body_height/2]){
cube([body_width,100,body_height]);
}
}
}
}
}
module shell(){
intersection(){
difference(){
body(radius_side + wall_thickness*2, height + wall_thickness*2, width_longest + wall_thickness*2);
translate([wall_thickness, wall_thickness, 0]){
body(radius_side, height, width_longest, 1);
}
}
translate([0,0,-(height+wall_thickness*2)/2]){
cube([width_longest+ wall_thickness*2,max_length,height+wall_thickness*2]);
}
}
}
module screwdown(){
difference(){
cube([15+(width_longest-width_shortest)/2+wall_thickness,15,wall_thickness]);
translate([7.5,7.5,0]){
screw_hole();
}
}
}
module screw_hole() {
// screw head that I measured maxes at 7mm
// screw thread is 3.5 mm
head = 7;
thread = 3.5 + 0.5;
translate([0,0,-20]){
cylinder(h=30, r=thread/2, $fn=FN);
}
translate([0,0,wall_thickness-(thread/2)]){
cylinder(h=head-(thread/2), r1=thread/2, r2=head);
}
}
module assembly(){
shell();
translate([-15,0,- height/2 -wall_thickness]){
screwdown();
}
translate([width_longest+wall_thickness*2+15,0,- height/2 -wall_thickness]){
mirror([1,0,0]){
screwdown();
}
}
}
translate([0,0,height/2+wall_thickness]){
assembly();
}