3d/Matekiste_Laser_Stencil.scad
2017-12-20 20:19:04 +01:00

108 lines
3.5 KiB
OpenSCAD

round_psu_cable_plane(300, 200, 5, 20, 20, 10, 40, 90, 90, 90);
RESOLUTION=36;
/*
* Simple, base angular plane with four holes
*/
module base_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y) {
difference() {
// base square
square([width, height]);
// holes
translate([hole_spacing_x, hole_spacing_y])
circle(d=hole_size, $fn=RESOLUTION);
translate([width - hole_spacing_x, hole_spacing_y])
circle(d=hole_size, $fn=RESOLUTION);
translate([hole_spacing_x, height - hole_spacing_y])
circle(d=hole_size, $fn=RESOLUTION);
translate([width - hole_spacing_x, height - hole_spacing_y])
circle(d=hole_size, $fn=RESOLUTION);
}
}
/*
* base_plane(...) with rounded edges, using helper function __radius_cutout(...)
*/
module round_base_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius) {
difference() {
base_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y);
translate([width-radius, height-radius])
__radius_cutout(radius);
translate([radius, height-radius])
rotate([0, 0, 90])
__radius_cutout(radius);
translate([radius, radius])
rotate([0, 0, 180])
__radius_cutout(radius);
translate([width-radius, radius])
rotate([0, 0, 270])
__radius_cutout(radius);
}
}
/*
* Rounded base plane with cutout for the PSU
*/
module round_psu_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius, psu_width, psu_height) {
difference() {
round_base_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius);
translate([width-psu_width, height/2-psu_height/2])
square([psu_width, psu_height]);
}
}
/*
* Rounded base plane with cutout for cables
*/
module round_cable_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius, cable_width, cable_height) {
difference() {
round_base_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius);
difference() {
union() {
translate([0, height/2-cable_height/2])
square([cable_width, cable_height]);
// Outer rounds
translate([radius, height/2-cable_height/2-radius])
rotate([0, 0, 90])
__radius_cutout(radius);
translate([radius, height/2+cable_height/2+radius])
rotate([0, 0, 180])
__radius_cutout(radius);
}
// Inner rounds
translate([cable_width-radius, height/2+cable_height/2-radius])
__radius_cutout(radius);
translate([cable_width-radius, height/2-cable_height/2+radius])
rotate([0, 0, 270])
__radius_cutout(radius);
}
}
}
/*
* Base plane with combined cutouts: for PSU and for cables
*/
module round_psu_cable_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius, psu_width, psu_height, cable_width, cable_height) {
intersection() {
round_psu_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius, psu_width, psu_height);
round_cable_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius, cable_width, cable_height);
}
}
/*
* Helper function for round edges
*/
module __radius_cutout(radius) {
difference() {
translate([radius/2, radius/2, 0])
square([radius, radius], center=true);
circle(radius, $fn=RESOLUTION);
}
}