// MAME-console 1.0 // (C) 2017 M4rc3lv // Printbed: 150x230 // Print with supports: yes (needed for the square holes) $fn=90; EXTRA_H=10; difference() { union() { difference() { roundedcube([218,144,20+EXTRA_H],radius=5,apply_to="ymax"); translate([3,3,3]) cube([212,132,30+EXTRA_H]); } translate([0,0,-2]) difference() { translate([3,3,3]) cube([212,132,14+EXTRA_H]); translate([6,6,0]) cube([210-5,130-5,50+EXTRA_H]); } } translate([4,133,5]) cube([210,10,20+EXTRA_H]); translate([7,137,8]) cube([204,10,20+EXTRA_H]); // Holes for HDMI and USB-power translate([30,-5,5]) { // USB-power Raspberry Pi translate([6.8-3,0,-1.25]) cube([7.5+6,15,8.5]); //3 // HDMI translate([10.2+6.8+7.5-5+2,0,-1.25]) cube([23,15,13.5]); } // Joystick port (USB-A) translate([170,-1,5])cube([15.5,20,9]); translate([162.5,10,9]) rotate([90,0,0]) cylinder(d=4,h=20); translate([162.5+30,10,9]) rotate([90,0,0])cylinder(d=4,h=20); } // Bars for screwing topplate translate([6,6,4]) cube([10,10,21]); translate([202,6,4]) cube([10,10,21]); translate([6,122,4]) cube([10,10,21]); translate([202,122,4]) cube([10,10,21]); // Raspberry Pi (not rendered when exporting STL) %translate([10,10,5]) { color("green") cube([85,59,3]); // USB color("pink") translate([6.8,0,3]) cube([7.5,5,4]); // HDMI color("pink") translate([10.2+6.8+7.5,0,3]) cube([15,5,7]); } module roundedcube(size = [1, 1, 1], center = false, radius = 0.5, apply_to = "all") { // If single value, convert to [x, y, z] vector size = (size[0] == undef) ? [size, size, size] : size; translate_min = radius; translate_xmax = size[0] - radius; translate_ymax = size[1] - radius; translate_zmax = size[2] - radius; diameter = radius * 2; module build_point(type = "sphere", rotate = [0, 0, 0]) { if (type == "sphere") { sphere(r = radius); } else if (type == "cylinder") { rotate(a = rotate) cylinder(h = diameter, r = radius, center = true); } } obj_translate = (center == false) ? [0, 0, 0] : [ -(size[0] / 2), -(size[1] / 2), -(size[2] / 2) ]; translate(v = obj_translate) { hull() { for (translate_x = [translate_min, translate_xmax]) { x_at = (translate_x == translate_min) ? "min" : "max"; for (translate_y = [translate_min, translate_ymax]) { y_at = (translate_y == translate_min) ? "min" : "max"; for (translate_z = [translate_min, translate_zmax]) { z_at = (translate_z == translate_min) ? "min" : "max"; translate(v = [translate_x, translate_y, translate_z]) if ( (apply_to == "all") || (apply_to == "xmin" && x_at == "min") || (apply_to == "xmax" && x_at == "max") || (apply_to == "ymin" && y_at == "min") || (apply_to == "ymax" && y_at == "max") || (apply_to == "zmin" && z_at == "min") || (apply_to == "zmax" && z_at == "max") ) { build_point("sphere"); } else { rotate = (apply_to == "xmin" || apply_to == "xmax" || apply_to == "x") ? [0, 90, 0] : ( (apply_to == "ymin" || apply_to == "ymax" || apply_to == "y") ? [90, 90, 0] : [0, 0, 0] ); build_point("cylinder", rotate); } } } } } } }