3d/Matekiste_Laser_Stencil.scad

246 lines
8.0 KiB
OpenSCAD

// top plane:
//round_psu_cable_fan_plane(360, 250, 6.5, 300, 180, 10, 41, 83, 90, 90);
// middle plane:
// round_psu_mainboard_plane(360, 250, 6.5, 300, 180, 10, 41, 83);
// bottom plane:
round_base_plane(360, 250, 6.5, 300, 180, 10);
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([(width-hole_spacing_x)/2, (height-hole_spacing_y)/2])
circle(d=hole_size, $fn=RESOLUTION);
translate([hole_spacing_x+(width-hole_spacing_x)/2, (height-hole_spacing_y)/2])
circle(d=hole_size, $fn=RESOLUTION);
translate([(width-hole_spacing_x)/2, height-(height-hole_spacing_y)/2])
circle(d=hole_size, $fn=RESOLUTION);
translate([hole_spacing_x+(width-hole_spacing_x)/2, height-(height-hole_spacing_y)/2])
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) {
intersection() {
base_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y);
__round_square(width, height, 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);
}
}
/*
* Base plane with combined cutouts: for PSU and mainboard bearings
*/
module round_psu_mainboard_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius, psu_width, psu_height) {
difference() {
round_psu_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius, psu_width, psu_height);
rotate([0, 0, 180])
translate([-310, -244])
__mainboard_bearings(230, 244);
}
}
/*
* Base plane with cutouts for two fans in the center
*/
module round_fan_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius) {
difference() {
round_base_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius);
// lower fan
translate([width/2-120/2, height/4-120/2])
__fan_cutout(120, 105, 5);
// upper fan
translate([width/2-120/2, height*3/4-120/2])
__fan_cutout(120, 105, 5);
}
}
/*
* Base plane with cutouts for psu, cables and fans
*/
module round_psu_cable_fan_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);
round_fan_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius);
}
}
/*
* 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);
}
}
/*
* Helper function for square with round edges
*/
module __round_square(width, height, radius) {
difference() {
square([width, height]);
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);
}
}
/*
* Helper function for fan cutout
*/
module __fan_cutout(outer_size, inner_size, bearing_size) {
// Bearing
translate([outer_size-(outer_size-inner_size)/2, outer_size-(outer_size-inner_size)/2])
circle(d=bearing_size, $fn=RESOLUTION);
translate([(outer_size-inner_size)/2, outer_size-(outer_size-inner_size)/2])
circle(d=bearing_size, $fn=RESOLUTION);
translate([outer_size-(outer_size-inner_size)/2, (outer_size-inner_size)/2])
circle(d=bearing_size, $fn=RESOLUTION);
translate([(outer_size-inner_size)/2, (outer_size-inner_size)/2])
circle(d=bearing_size, $fn=RESOLUTION);
// middle squares
translate([0, outer_size-inner_size, 0])
__round_square(outer_size, inner_size-(outer_size-inner_size), 5);
//translate([outer_size-inner_size, 0, 0])
//__round_square(inner_size-(outer_size-inner_size), outer_size, 5);
// round edges between middle squares
/*translate([outer_size-inner_size-2.5, outer_size-inner_size-2.5, 0])
__radius_cutout(2.5);
translate([outer_size-(outer_size-inner_size)+2.5, outer_size-inner_size-2.5, 0])
rotate([0, 0, 90])
__radius_cutout(2.5);
translate([outer_size-(outer_size-inner_size)+2.5, outer_size-(outer_size-inner_size)+2.5, 0])
rotate([0, 0, 180])
__radius_cutout(2.5);
translate([outer_size-inner_size-2.5, outer_size-(outer_size-inner_size)+2.5, 0])
rotate([0, 0, 270])
__radius_cutout(2.5);
*/
}
module __mainboard_bearings(mainboard_width, mainboard_height) {
// measured from a microATX (970M Pro3):
// * mainboard_width=230;
// * mainboard_height=244;
bearing_size=4;
// bottom row
translate([0, 5]) {
// inofficial hole added by ASROCK (970M Pro3)
// translate([5, 0])
// circle(d=bearing_size, $fn=RESOLUTION);
translate([63, 0])
circle(d=bearing_size, $fn=RESOLUTION);
translate([195, 0])
circle(d=bearing_size, $fn=RESOLUTION);
}
// middle row
translate([0, mainboard_height-80]) {
translate([63, 0])
circle(d=bearing_size, $fn=RESOLUTION);
translate([mainboard_width-10, 0])
circle(d=bearing_size, $fn=RESOLUTION);
}
// middle top row
translate([63, mainboard_height-14])
circle(d=bearing_size, $fn=RESOLUTION);
// nearly top left hole
translate([mainboard_width-10, mainboard_height-34])
circle(d=bearing_size, $fn=RESOLUTION);
// top left hole
// inofficial hole added by ASROCK (970M Pro3)
// translate([5, mainboard_height-5])
// circle(d=bearing_size, $fn=RESOLUTION);
}