Rounding the edge of a hole? September 25, 2019 04:58PM |
Registered: 10 years ago Posts: 893 |
bodyWidth = 25; bodyHeight = 15; slotWidth = 6; slotHeight = 10; $fn = 50; module slot() { rotate( [-90, -90, 0] ) union() { cylinder(d = slotWidth, h = bodyWidth + 2); translate( [0, -slotWidth/2, 0] ) cube( [bodyHeight - slotHeight, slotWidth, bodyWidth + 2] ); translate( [bodyHeight - slotHeight, 0, 0] ) cylinder(d = slotWidth, h = bodyWidth + 2); } } difference() { cube(bodyWidth); translate( [bodyWidth/2, -1, bodyWidth/2] ) #slot(); }
Re: Rounding the edge of a hole? September 25, 2019 10:53PM |
Admin Registered: 13 years ago Posts: 7,148 |
Re: Rounding the edge of a hole? September 26, 2019 12:29AM |
Admin Registered: 13 years ago Posts: 7,148 |
module Chamfered_Cylinder(CylinderDiameter,CylinderHeight,ChamferRadius,ChamferFacits) { difference () { union() { //Central Cyclinder cylinder(d=CylinderDiameter,h=CylinderHeight); //Bottom Chamfer cylinder translate ([0,0,0]) cylinder(d=CylinderDiameter+ChamferRadius,h=ChamferRadius/2); //Top Chamfer cylinder translate ([0,0,CylinderHeight-ChamferRadius/2]) cylinder(d=CylinderDiameter+ChamferRadius,h=ChamferRadius/2); } //Generate Bottom chamfer for (i = [0:1:ChamferFacits-1]) { rotate([90,0,i*360/ChamferFacits+90]) translate([CylinderDiameter/2+ChamferRadius/2,ChamferRadius/2,-ChamferRadius/2]) cylinder(d=ChamferRadius, h=ChamferRadius); } //generate Top chamfer for (i = [0:1:ChamferFacits-1]) { rotate([90,0,i*360/ChamferFacits+90]) translate([CylinderDiameter/2+ChamferRadius/2,CylinderHeight-ChamferRadius/2,-ChamferRadius/2]) cylinder(d=ChamferRadius, h=ChamferRadius); } } } CylinderDiameter = 15; CylinderHeight = 40; ChamferRadius = 5; ChamferFacits = 50; //Its best to have the cylinder facits and the Chamfer facits the same value. $fn=ChamferFacits; //Extra cylinder on bottom to appease the scad gods translate ([0,0,-ChamferRadius]) cylinder(d=CylinderDiameter+ChamferRadius,h=ChamferRadius); //Extra cylinder on top to appease the scad gods translate ([0,0,CylinderHeight]) cylinder(d=CylinderDiameter+ChamferRadius,h=ChamferRadius); //The Cylinder with chamfer Chamfered_Cylinder(CylinderDiameter,CylinderHeight,ChamferRadius,ChamferFacits);
Re: Rounding the edge of a hole? September 26, 2019 12:52AM |
Registered: 9 years ago Posts: 978 |
minkowski() { difference() { cube(bodyWidth); translate( [bodyWidth/2, -1, bodyWidth/2] ) slot(); } sphere(1); }
Re: Rounding the edge of a hole? September 26, 2019 04:24AM |
Registered: 10 years ago Posts: 893 |
Re: Rounding the edge of a hole? September 26, 2019 08:06AM |
Registered: 10 years ago Posts: 893 |
Re: Rounding the edge of a hole? September 26, 2019 08:51AM |
Admin Registered: 13 years ago Posts: 7,148 |
Re: Rounding the edge of a hole? September 26, 2019 10:36AM |
Registered: 10 years ago Posts: 893 |
Re: Rounding the edge of a hole? September 26, 2019 11:49AM |
Registered: 10 years ago Posts: 590 |
// chamfercyl - create a cylinder with round chamfered ends module chamfercyl( r, // cylinder radius h, // cylinder height b=0, // bottom chamfer radius (=0 none, >0 outside, <0 inside) t=0, // top chamfer radius (=0 none, >0 outside, <0 inside) offset=[[0,0]], // optional offsets in X and Y to create // convex hulls at slice level slices=10, // number of slices used for chamfering eps=0.01, // tiny overlap of slices ){ astep=90/slices; hull()for(o = offset) translate([o[0],o[1],abs(b)-eps])cylinder(r=r,h=h-abs(b)-abs(t)+2*eps); if(b)for(a=[0:astep:89.999])hull()for(o = offset) translate([o[0],o[1],abs(b)-abs(b)*sin(a+astep)-eps]) cylinder(r2=r+(1-cos(a))*b,r1=r+(1-cos(a+astep))*b,h=(sin(a+astep)-sin(a))*abs(b)+2*eps); if(t)for(a=[0:astep:89.999])hull()for(o = offset) translate([o[0],o[1],h-abs(t)+abs(t)*sin(a)-eps]) cylinder(r1=r+(1-cos(a))*t,r2=r+(1-cos(a+astep))*t,h=(sin(a+astep)-sin(a))*abs(t)+2*eps); } // now build David's example, the cube with the chamfered hole (viewed from below to make things easy...) $fn=36; difference(){ translate([-12.5,-12.5,0])cube(25); chamfercyl(3,25,3,3,[[-2,0],[2,0]]); }
translate([-60,0,0])chamfercyl(10,50,0,12); translate([-30,0,0])chamfercyl(10,50,-3,-6); translate([0,0,0])chamfercyl(10,50,7,-3); translate([30,0,0])chamfercyl(10,50,-9,2); translate([60,0,0])chamfercyl(10,50,4,4);gives the following cylinders:
Re: Rounding the edge of a hole? September 26, 2019 12:34PM |
Admin Registered: 13 years ago Posts: 7,148 |
Re: Rounding the edge of a hole? September 26, 2019 12:53PM |
Registered: 10 years ago Posts: 590 |
Re: Rounding the edge of a hole? September 26, 2019 02:58PM |
Registered: 9 years ago Posts: 978 |
Quote
David J
Right - I tried using minkowski... life is too short... and all of my dimensions were screwed up (as expected); it would be a PITA to make size adjustments to compensate. So, good idea, but too painful.
Re: Rounding the edge of a hole? September 26, 2019 03:43PM |
Registered: 10 years ago Posts: 893 |
Quote
frankvdh
Quote
David J
Right - I tried using minkowski... life is too short... and all of my dimensions were screwed up (as expected); it would be a PITA to make size adjustments to compensate. So, good idea, but too painful.
Right... I'd forgotten that Minkowski with a sphere moves the surface by the radius of the sphere. For sphere of radius 1, you need to subtract 1 from each of your width and height variables.
Re: Rounding the edge of a hole? September 26, 2019 03:48PM |
Registered: 10 years ago Posts: 893 |
Quote
enif
Interesting problem...
Here my approach, which is a bit different. Instead of subtracting cylinders to get the chamfer, I construct the cylinder in slices:
-- snip for brevity ---
Re: Rounding the edge of a hole? September 29, 2019 04:06AM |
Registered: 10 years ago Posts: 893 |
Re: Rounding the edge of a hole? September 29, 2019 06:28AM |
Registered: 10 years ago Posts: 590 |
Re: Rounding the edge of a hole? September 29, 2019 08:13AM |
Registered: 10 years ago Posts: 893 |
Re: Rounding the edge of a hole? February 03, 2020 11:45PM |
Registered: 10 years ago Posts: 39 |
module fillet_cylinder( r, // cylinder radius h, // cylinder height b=0, // bottom chamfer radius (=0 none, >0 outside, <0 inside) t=0, // top chamfer radius (=0 none, >0 outside, <0 inside, deg=10 // degrees per rib of fillet ) rotate_extrude() polygon(concat([[0,h],[0,0]], [for(a=[0:deg:90]) [r-b*(sin(a)-1), abs(b)*(1-cos(a))]], //bottom fillet [for(a=[90:-deg:0]) [r-t*(sin(a)-1), h-abs(t)*(1-cos(a))]])); //top fillet
Re: Rounding the edge of a hole? November 11, 2020 06:35AM |
Registered: 4 years ago Posts: 1 |
Re: Rounding the edge of a hole? April 28, 2022 03:41AM |
Registered: 2 years ago Posts: 2 |
Re: Rounding the edge of a hole? April 28, 2022 04:55AM |
Registered: 2 years ago Posts: 2 |
Re: Rounding the edge of a hole? April 08, 2023 09:40PM |
Registered: 1 year ago Posts: 26 |