include use use $fs = 1; // tolerance. lining up the extrusions and cuts with zero tolerance causes very thin walls, // so i offset those to make the model actually contiguous. Tol = 0.1; // simple box-shaped body; preserve for easier debugging module BodyBox() { cube([BodyWidth, BodyLength, BodyHeight], center=false); } // return the kernel which can be convolved with the box body to produce the actual body module BodyConvolve(Tol=Tol) { minkowski() { // cylinder rounds the four corners of the phone cylinder(r=BodyRadXY-BodyRadFrontZ, h=Tol, center=true); // sphere rounds the thickness of the phone // in actuality this shouldn't be symmetric (the screen and back cover have different radii), // but using a single radius is Good Enough sphere(r=BodyRadFrontZ); // cylinderY(r=BodyRadFrontZ, h=Tol, center=true); // cylinderX(r=BodyRadFrontZ, h=Tol, center=true); } } module Body() { translate([BodyRadXY, BodyRadXY, BodyRadFrontZ]) minkowski() { cube([BodyWidth-2*BodyRadXY, BodyLength-2*BodyRadXY, BodyHeight-2*BodyRadFrontZ], center=false); BodyConvolve(); } } module Phone(Box=false) { difference() { union() { if (Box) { BodyBox(); } else { Body(); } Volume(2); Power(2); Camera(2, Box=Box); } union() { translate([0, Tol, 0])Usb(2); translate([0, -Tol, 0])Aux(2); } } } Phone(); // debugging: // translate([0, 0, 20])Phone(Box=true); // translate([0, 0, 80])BodyConvolve();