//############################################# // Parametized box SCAD file // written by Norman Deschamps // Version 6 - September 2018 //############################################# //all radius have to be less than half of length or width $fn=100; //======================================================================= //=========== Dimensions You Need to Change For Your Box ====================== //======================================================================= //Box dimensions width= 60; //x length= 60; //y h = 40; //z //Corner radii: set to .01 if you don't want a large curve for that particular corner. cant be 0 r1 = 8; //top right corner r2 = 8; //top left corner r3 = .01; // r4 = .01; fillet = 3; //should be a max of 3, shouldn't need to change; wall = 1.2; //should not be less than about 1.2 for strength panelHeight = 20; //a panel height of 20 gives room for two lines of text. // Choose what part you want to build part = "box"; // [box:Box, words:Words, both:Both] //======================================================================= //======================= Panel Text For Your Box =========================== //======================================================================= text_1 = "SOMETHING"; // put as "" if don't want text text_2 = "WICKED"; text_back = "COMES"; // First text line font size text_size = 5; //[.1:.1:50] //Min Text size number_size = 5; text_font = "CasablancaAntiquePlain:style=Bold"; number_font = "Impact"; // First text line horizontal offset (> 0 - right, < 0 - left) text_1_x_offset = 0; // limited by l value below text_b_z_offset = 10; // height below top of wall for rear wall text text_extrusion = 0.8; //how far out from the panel the text sticks out //============================================================ //============================================================ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //!!!!!!!!! DO NOT CHANGE ANYTHING BELOW THIS LINE !!!!!!!!!!!!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++ COMPUTED VARIABLES +++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ x_o = width - 2*fillet; y_o = length - 2*fillet; h_o = h - fillet; //Computed inside dimensions x_i = width - 2*wall - 2*fillet; y_i = length - 2*wall - 2*fillet; //Computed inside box corners for corners with radii larger than wall thickness r1_i = r1 > wall ? r1 - wall : r1; r2_i = r2 > wall ? r2 - wall : r2; r3_i = r3 > wall ? r3 - wall : r3; r4_i = r4 > wall ? r4 - wall : r4; //Computed sloped panel dimension x_p = width - 2*fillet; y_p = panelHeight/2; z_p = panelHeight - fillet; x_pi = width - 2*wall - 2*fillet; //Computed panel text dimensions //for panel z offset, take size of panel and size of text, and use the same gap above, //below and in between the text //Adjust gaps for if we have 1 or 2 lines of text text_gaps = text_2 == "" ? ((panelHeight - fillet)/sin(60) - text_size)/2 : ((panelHeight - fillet)/sin(60) - 2*text_size)/3; text_1_z_offset = sin(60)*(text_gaps + text_size); // [-100:0.1:100] text_2_z_offset = sin(60)*(2*text_gaps + 2*text_size); // [-100:0.1:100] Also add in text size x_panel = width/2; z_panel1 = h - text_1_z_offset; y_panel1 = length - wall/sin(60) - (y_p - (text_1_z_offset)/tan(60)); //angle is always 60 degrees z_panel2 = h - text_2_z_offset; y_panel2 = length - wall/sin(60) - (y_p - (text_2_z_offset)/tan(60)); //angle is always 60 degrees //Computed rear wall text dimensions x_back = ((width - r1 - r2)/2) + r1; //puts the text between the two radii on the back wall y_back = 0; z_back = h - text_b_z_offset; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //============Main Program====================================== if (part == "box") { translate([-width/2, -length/2, 0]) box(); } else if (part == "words") { translate([-width/2, -length/2, 0]) words(); } else if (part == "both") { translate([-width/2, -length/2, 0]) box(); translate([-width/2, -length/2, 0]) words(); } module box(){ //Top difference is used to remove the top fillets off the box, also rotates on z axis since front is -y on Qidi difference(){ //Union combines the box with the sloped panel union(){ //creates the box with different radii on each corner difference(){ //create outside box translate([fillet, fillet, fillet])minkowski(){ roundedcube(x_o, y_o, h_o, r1, r2, r3, r4); sphere(fillet); } //create inside hole of box translate([wall+fillet, wall+fillet, wall+fillet])minkowski(){ roundedcube(x_i, y_i, h+10, r1_i, r2_i, r3_i, r4_i); sphere(fillet); } //remove sloped section of box translate([-fillet, length - y_p - fillet, h - z_p])cube(size = [width+2*fillet, y_p+2*fillet, z_p*2+fillet], center = false); //add back wall text if (text_back != ""){ translate([x_back, y_back, z_back]) rotate([90, 0, 180]) linear_extrude(height = wall + text_extrusion) text(text_back, halign = "center", valign = "baseline", size = number_size, font = number_font); } } //Creates the top sloped panel wall of the box by creating a prism shell difference(){ //create outside of panel translate([fillet, length-fillet, h - z_p])minkowski(){ prism(x_p, -y_p, z_p); sphere(fillet); } //create inside hole of panel translate([wall+fillet, length-wall-fillet, h - z_p - wall])minkowski(){ prism(x_pi, -(y_p - wall)*1.25, (z_p - wall)*1.25); sphere(fillet); } //remove bottom of sloped section translate([wall,length-y_p-wall-2*fillet, h - z_p-2*fillet])cube(size = [width-2*wall, y_p+2*fillet, 2*fillet], center = false); //Put holes where the text will be if (text_1 != ""){ translate([x_panel, y_panel1, z_panel1]) rotate([60, 0, 180]) linear_extrude(height = wall + text_extrusion) text(text_1, halign = "center", valign = "baseline", size = text_size, font = text_font); } if (text_2 != ""){ translate([x_panel, y_panel2, z_panel2]) rotate([60, 0, 180]) linear_extrude(height = wall + text_extrusion) text(text_2, halign = "center", valign = "baseline", size = text_size, font = text_font); } } } //remove the top fillet translate([0,0,h])cube([width, length, 2*fillet], false); } } module words(){ if (text_back != ""){ translate([x_back, y_back, z_back]) rotate([90, 0, 180]) linear_extrude(height = wall + text_extrusion) text(text_back, halign = "center", valign = "baseline", size = number_size, font = number_font); } if (text_1 != ""){ translate([x_panel, y_panel1, z_panel1]) rotate([60, 0, 180]) linear_extrude(height = wall + text_extrusion) text(text_1, halign = "center", valign = "baseline", size = text_size, font = text_font); } if (text_2 != ""){ translate([x_panel, y_panel2, z_panel2]) rotate([60, 0, 180]) linear_extrude(height = wall + text_extrusion) text(text_2, halign = "center", valign = "baseline", size = text_size, font = text_font); } } module prism(l, w, h){ polyhedron( points=[[0,0,0], [l,0,0], [l,w,0], [0,w,0], [0,w,h], [l,w,h]], faces=[[0,1,2,3],[5,4,3,2],[0,4,5,1],[0,3,4],[5,2,1]] ); } module roundedcube(xdim ,ydim ,zdim, rdim, rdim2, rdim3, rdim4){ hull(){ translate([rdim,rdim,0])cylinder(h=zdim,r=rdim); translate([xdim-rdim2,rdim2,0])cylinder(h=zdim,r=rdim2); translate([rdim3,ydim-rdim3,0])cylinder(h=zdim,r=rdim3); translate([xdim-rdim4,ydim-rdim4,0])cylinder(h=zdim,r=rdim4); } }