KeyV2/key_mold.scad

181 lines
3.9 KiB
OpenSCAD
Raw Normal View History

2018-02-18 01:34:56 +00:00
include <keys.scad>
2018-06-03 17:29:51 +00:00
platform_width = 30;
platform_height = 4;
// height difference between bottom and top of platform
platform_slant = 3;
2018-06-03 17:29:51 +00:00
minimum_height = 12;
//minimum mold thickness
2018-06-03 17:29:51 +00:00
extra = 9;
//thicknesses of the mold
side_thickness = 2;
bottom_thickness = 2;
2018-06-03 17:29:51 +00:00
// computed variables
inner_side = platform_width + extra * 2;
total_side = inner_side + side_thickness * 2;
// minimum_height of bottom, non-flared box
bottom_box_height = 5 + bottom_thickness;
2018-02-18 01:34:56 +00:00
function hypo(num) = sqrt(pow(num,2) / 2);
2018-02-18 01:34:56 +00:00
module bottom_box() {
difference(){
//outer box
2018-06-03 17:29:51 +00:00
cube([total_side, total_side, bottom_box_height]);
//inner box
2018-02-18 01:34:56 +00:00
translate([ side_thickness, side_thickness, bottom_thickness]) {
2018-06-03 17:29:51 +00:00
cube([inner_side, inner_side, bottom_box_height - bottom_thickness + .02]);
}
}
2018-02-18 01:34:56 +00:00
}
2018-02-18 01:34:56 +00:00
module slanted_box() {
2018-06-03 17:29:51 +00:00
translate([total_side / 2, total_side / 2, bottom_box_height]) rotate([0,0,45]) difference(){
//outer box
2018-02-18 01:34:56 +00:00
cylinder(
2018-06-03 17:29:51 +00:00
h = minimum_height + extra - bottom_box_height + platform_height,
r1 = hypo(total_side),
r2 = hypo(total_side + 3),
$fn=4
);
//inner box
2018-02-18 01:34:56 +00:00
translate([0,0,-0.01]) cylinder(
2018-06-03 17:29:51 +00:00
minimum_height + extra - bottom_box_height + .02 + platform_height,
hypo(inner_side),
hypo(inner_side + 3),
$fn=4
);
}
2018-02-18 01:34:56 +00:00
}
module platform() {
//platform
2018-06-03 17:29:51 +00:00
/* translate([
side_thickness + extra,
side_thickness + extra,
bottom_thickness
2018-06-03 17:29:51 +00:00
]) cube([platform_width, platform_width, platform_height]); */
translate([
side_thickness + extra + platform_width/2,
side_thickness + extra + platform_width/2,
bottom_thickness
]) rotate([0,0,45]) cylinder(r1=hypo(platform_width), r2=hypo(platform_width) - platform_slant, h=platform_height, $fn=4);
2018-02-18 01:34:56 +00:00
}
2018-02-18 01:34:56 +00:00
module registration() {
positions = [
[// bottom left
2018-06-03 17:29:51 +00:00
side_thickness + extra / 2 + 1,
side_thickness + extra / 2 + 1,
2018-02-18 01:34:56 +00:00
bottom_thickness
],
[// top left
2018-06-03 17:29:51 +00:00
side_thickness + extra / 2 + 1,
side_thickness + platform_width + extra * 1.5 - 1,
2018-02-18 01:34:56 +00:00
bottom_thickness
],
[// bottom right
2018-06-03 17:29:51 +00:00
side_thickness + platform_width + extra * 1.5 - 1,
side_thickness + extra / 2 + 1,
2018-02-18 01:34:56 +00:00
bottom_thickness
],
[// top right
2018-06-03 17:29:51 +00:00
side_thickness + platform_width + extra * 1.5 - 1,
side_thickness + platform_width + extra * 1.5 - 1,
2018-02-18 01:34:56 +00:00
bottom_thickness
]
];
2018-06-03 17:29:51 +00:00
for (index = [0:len(positions)-1]) {
position = positions[index];
translate(position) {
// dont mind the math
rotate([0,0,45 / (index % 2 * 0.5 + 1)]) {
cylinder(platform_height / 2,extra/3, 2, $fn=(index % 2 * 2 + 4));
}
}
2018-02-18 01:34:56 +00:00
}
}
2018-02-18 01:34:56 +00:00
module key_for_mold(wall_thickness = 20) {
translate([
2018-06-03 17:29:51 +00:00
total_side / 2,
total_side / 2,
platform_height + bottom_thickness
2018-02-18 01:34:56 +00:00
]) {
$wall_thickness = wall_thickness;
$support_type = false;
2018-06-03 17:29:51 +00:00
sa_row(1) key();
2018-02-18 01:34:56 +00:00
}
}
module bottom_mold(){
bottom_box();
slanted_box();
platform();
registration();
/* key_for_mold(); */
}
module top_mold(){
difference(){
//outer box
cube([
total_side,
total_side,
2018-06-03 17:29:51 +00:00
minimum_height + extra + bottom_thickness,
]);
//inner box
translate([
side_thickness,
side_thickness,
0
]) {
cube([
2018-06-03 17:29:51 +00:00
inner_side,
inner_side,
minimum_height + extra + bottom_thickness,
]);
}
}
}
2018-06-03 17:29:51 +00:00
// for calculating how much mold material to use!
module difference_box() {
2018-02-18 01:34:56 +00:00
scale(.99) union() {
cube([total_side, total_side, bottom_box_height + bottom_thickness]);
translate([total_side / 2, total_side / 2, bottom_box_height + bottom_thickness]) rotate([0,0,45]){
//outer box
cylinder(
2018-06-03 17:29:51 +00:00
minimum_height + extra - bottom_box_height,
2018-02-18 01:34:56 +00:00
hypo(total_side),
hypo(total_side + 3),
$fn=4
);
}
}
}
difference() {
2018-06-03 17:29:51 +00:00
/* difference_box(); */
2018-02-18 01:34:56 +00:00
2018-06-03 17:29:51 +00:00
/* bottom_mold(); */
2018-02-18 01:34:56 +00:00
}
/* key_for_mold(0); */
2018-06-03 17:29:51 +00:00
translate([0,0,0]) top_mold();