Help with rounded edge December 09, 2016 05:22PM |
Registered: 10 years ago Posts: 24 |
/* Variable size back box lid. Use the same dimensions as the box you programmed earlier. You do not need to specify height as it will use wall thickness to determine it. Input format: lid(length,width,wall thickness,screw hole diameter); */ $fn=100; //# of facets in curves lid(100,90,3,3); module lid(xdim,ydim,wall,screw) { xdim1 = xdim + (wall*2) + ((screw + 6) * 2); //full box x dimension ydim1 = ydim + (wall*2) + ((screw + 6) * 2); //full box y dimension difference() //screw holes { union() //bottom and top halves of lid { translate([wall+0.2,wall+0.2,0]) roundedrect((xdim1 - (wall*2) - 0.4),(ydim1 - (wall*2) - 0.4),wall-0.2,(wall-1)); //inner lid translate([0,0,wall-0.3]) roundedrect(xdim1,ydim1,wall,(wall-1)); //outer lid } translate([(wall + 3 + (screw / 2)),(wall + 3 + (screw / 2)),0]) cylinder(wall,(screw/2),(screw/2)); //X0, Y0 hole translate([(wall + 3 + (screw / 2)),(wall + 3 + (screw / 2)),wall]) cylinder(wall,screw/2,(screw * 1.5)); //X0 Y0 hole flare translate([(wall + 3 + (screw / 2)),((wall*2) + ydim + screw + 9 + (screw/2)),0]) cylinder(wall,(screw/2),(screw/2)); //X0, Y+ hole translate([(wall + 3 + (screw / 2)),((wall*2) + ydim + screw + 9 + (screw/2)),wall]) cylinder(wall,screw/2,(screw * 1.5)); //X0 Y+ hole flare translate([(wall + xdim + screw + 9 + (screw/2) + 0.1),(wall + 3 + (screw / 2)),0]) cylinder(wall,(screw/2),(screw/2)); //X+, Y0 hole translate([(wall + xdim + screw + 9 + (screw/2) + 0.1),(wall + 3 + (screw / 2)),wall]) cylinder(wall,screw/2,(screw * 1.5)); //X+ Y0 hole flare translate([(wall + xdim + screw + 9 + (screw/2) + 0.1),((wall*2) + ydim + screw + 9 + (screw/2)),0]) cylinder(wall,(screw/2),(screw/2)); //X+, Y+ hole translate([(wall + xdim + screw + 9 + (screw/2) + 0.1),((wall*2) + ydim + screw + 9 + (screw/2)),wall]) cylinder(wall,screw/2,(screw * 1.5)); //X+ Y+ hole flare /* LCD is a module to create a hole for an LCD in the lid. Specify the width (X) and the height (y) and any offest from center required (X and Y). A negative offset takes you closer to zero on that axis. If no offest is required, use zero. Format: LCD(width,height,xoffset,yoffset,xdim1,ydim1,wall); */ lcd(41.5,13.5,-3,20,xdim1,ydim1,wall); /* LCDHoles is the mounting holes for the LCD (if necessary). Specify the X and Y dimensions between hole centers, the offsets used for the LCD window, and the hole diameter. Format: lcdholes(xdim,ydim,xoffset,yoffset,hole diameter,xdim1,ydim1,wall); */ //lcdholes(30.48,17.78,-3,20,3,xdim1,ydim1,wall); /* Holes is a module that creates a single hole, Specify x,y location and the diameter of the hole. Repeat the call as many times as you need. */ holes((xdim1 / 2),35,14,wall); //pushbutton hole holes(30,35,7,wall); //power switch } } module roundedrect(xdim2,ydim2,zdim2,rdim) { hull() { translate([rdim,rdim,0]) cylinder(zdim2,rdim,rdim); //left front translate([rdim,ydim2,0]) cylinder(zdim2,rdim,rdim); //left rear translate([xdim2-rdim,rdim,0]) cylinder(zdim2,rdim,rdim); //right front translate([xdim2-rdim,ydim2,0]) cylinder(zdim2,rdim,rdim); //left rear } } module lcd(xdim2,ydim2,xoffset,yoffset,xtot2,ytot2,wall2) { side = ((xtot2 - xdim2) / 2) + xoffset + wall2; up = ((ytot2 - ydim2) / 2) + yoffset + wall2; translate([side,up,0]) cube([xdim2,ydim2,(wall2 * 2) +1]); } module lcdholes(xdim3,ydim3,xoffset1,yoffset1,hole,xtot1,ytot1,wall1) { side1 = ((xtot1 - xdim3) / 2) + xoffset1; up1 = ((ytot1 - ydim3) / 2) + yoffset1; translate([side1,up1,0]) cylinder(wall1,hole / 2,hole / 2); //X0 Y0 hole translate([side1,up1,wall1]) cylinder(wall1,hole / 2,hole * 1.5); //X0 Y0 hole flare translate([side1,wall1 + up1 + ydim3,0]) cylinder(wall1,hole / 2,hole / 2); //X0 Y+ hole translate([side1,wall1 + up1 + ydim3,wall1]) cylinder(wall1,hole / 2,hole * 1.5); //X0 Y+ hole flare translate([(wall1 + side1 + xdim3),up1,0]) cylinder(wall1,hole / 2,hole / 2); //X+ Y0 hole translate([(wall1 + side1 + xdim3),up1,wall1]) cylinder(wall1,hole / 2,hole * 1.5); //X+ Y0 hole flare translate([(wall1 + side1 + xdim3),wall1 + up1 + ydim3,0]) cylinder(wall1,hole / 2,hole / 2); //X+ Y+ hole translate([(wall1 + side1 + xdim3),wall1 + up1 + ydim3,wall1]) cylinder(wall1,hole / 2,hole * 1.5); //X+ Y+ hole flare } module holes(x2,y2,d2,wall3) { translate([x2,y2,0]) cylinder((wall3 * 2) + 1,(d2 /2),(d2 /2)); }
Re: Help with rounded edge December 09, 2016 10:32PM |
Registered: 10 years ago Posts: 782 |
Re: Help with rounded edge December 10, 2016 01:41AM |
Registered: 13 years ago Posts: 862 |
Re: Help with rounded edge December 10, 2016 04:01AM |
Registered: 10 years ago Posts: 590 |
// construct a rectangle with rounded corners but a flat bottom module FlatBottomRoundRect(length,width,height,radius){ // iterate over the 4 corners hull()for(sx=[-1,1])for(sy=[-1,1])scale([sx,sy,1]){ // lower cylindric part if(height>radius)translate([length/2-radius,width/2-radius,0]) cylinder(r=radius,h=height-radius); // upper spheric part intersection(){ // sphere translate([length/2-radius,width/2-radius,height-radius]) sphere(r=radius); // clip shere at bottom plane if(height<2*radius)translate([length/2-radius,width/2-radius,0]) cylinder(r=radius,h=height); } } }
Re: Help with rounded edge December 10, 2016 02:16PM |
Registered: 9 years ago Posts: 978 |
Quote
Replace
So minkowski the flat cube with a small sphere, (After the merge, it will be bigger 1/2 of the diameter)
Scale down 1/2 of the diameter of the sphere
cut off (difference) a bigger cube of the side that should not be rounded
Add all other parts
minkowski() { cube(50); difference() { sphere($fn=20, 10); translate([-10,-10,-20]) cube(20); } }
Re: Help with rounded edge December 10, 2016 04:30PM |
Registered: 10 years ago Posts: 24 |