In this case I join two cylinders using unionRound() and then subtract this from a cube. Easy to extend for the oval'ed slot case.

module unionRound(r, detail = 8) {

epsilon = 1e-6;

children(0);

children(1);

step = 90 / detail;

for (i = [0: detail-1]) {

{

x = r - sin(i * step ) * r;

y = r - cos(i * step ) * r;

xi = r - sin((i * step + step) ) * r;

yi = r - cos((i * step + step) ) * r;

color(rands(0, 1, 3, i))

hull() {

intersection() {

// shell(epsilon)

clad(x) children(0);

// shell(epsilon)

clad(y) children(1);

}

intersection() {

// shell(epsilon)

clad(xi) children(0);

// shell(epsilon)

clad(yi) children(1);

}

}

}

}

}

// unionRound helper expand by r

module clad(r) {

minkowski() {

children();

// icosphere(r,2);

isosphere(r,70);

}

}

// unionRound helper

module shell(r) {

difference() {

clad(r) children();

children();

}

}

/*

// The following is a sphere with some equidistant properties.

// Not strictly necessary

Kogan, Jonathan (2017) "A New Computationally Efficient Method for Spacing n Points on a Sphere," Rose-Hulman Undergraduate Mathematics Journal: Vol. 18 : Iss. 2 , Article 5.

Available at: [scholar.rose-hulman.edu] */

function sphericalcoordinate(x,y)= [cos(x )*cos(y ), sin(x )*cos(y ), sin(y )];

function NX(n,x)=

let(toDeg=57.2958,PI=acos(-1)/toDeg,

start=(-1.+1./(n-1.)),increment=(2.-2./(n-1.))/(n-1.) )

[ for (j= [0:n-1])let (s=start+j*increment )

sphericalcoordinate( s*x*toDeg, PI/2.* sign(s)*(1.-sqrt(1.-abs(s)))*toDeg)];

function generatepoints(n)= NX(n,0.1+1.2*n);

module isosphere(r,detail){

a= generatepoints(detail);

scale(r)hull()polyhedron(a,[[for(i=[0:len(a)-1])i]]);

}

$fn=60;

difference()

{

cube([20,20,10],center=true);

unionRound(4, detail = 10)

{

translate([0,0,10])

cylinder(h=10,d=20,center=true);

cylinder(h=20,d=5,center=true);

}

}]]>

Just a pig to rewrite all these modules in subroutines to be applied in different parts of the design, and again, if you have many it will be slow, but probably faster then minkowsky. Where the previous solution crashed on my pc, this reviewed in about 1 minute.

$fn=64;

based=40;

baseh=10;

bodyd=20;

bodyh=10;

trans=50;

//calling parts

for(a=[0:1:trans])

translate([a,0,0])pin_base();

hull(){

pin_body();

translate([trans,0,0])pin_body();

}

hull(){

pin_top();

translate([trans,0,0])pin_top();

}

//base

module torus_cut(){

rotate_extrude(angle=360) translate([based/2, 0, 0])circle(baseh);

}

module pin_base(){

difference(){

cylinder(h=baseh,d=based,center=true);

translate([0,0,baseh/2])torus_cut();

}

}

//body

module pin_body(){

translate([0,0,baseh/2+bodyh/2])cylinder(h=baseh,d=bodyd,center=true);

}

//top

module pin_top(){

translate([0,0,baseh/2+bodyh])sphere(d=bodyd);

}]]>

I take your word for it that it is faster then minkowski (which I avoid like the plague for being too slow to be useful) but IMHO this is still not useful either. My code was only 17 lines long! (which I had not saved before the crash)

I might try something else later, for which I got the idea looking at your solution. Split the pin I try to make in 3 parts, base, center and tip.

base is a large cylinder with a torus taken off it so it creates the bottom flare. center is just a cylinder, top is just a sphere.

Now translate to the length of the tab I need to make, and hull each of the three parts separately. Then put them in a module and use them to difference out from a cube.....need to try this to see if it will be just as slow.

So I still love Openscad to bits, but until something works better then these solutions my designs will resemble an mine-craft landscape, mostly anyway. Thanks to chamfer.scad though, just takes the sharp edges off this problem a little ;-)]]>

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

As an easter egg, if you also pass in $fn=4, you'll get a filletted square prism.]]>

This is perfect - thanks for giving credit :)

Since I am also quite active on Thingiverse, you could -but only if you like!- underlay the word "enif" with a link to my thingiverse account, which is www.thingiverse.com/enif .]]>

Desk cable organiser

Enif - have a look at what I did with your code, and let me know if you're happy with what I've done. Also, if you want a more detailed credit in the code and on Thingiverse then please PM me with your details.

Many thanks to all,

David]]>

]]>Quoteenif

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 ---

Quote

**frankvdh**

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.

QuoteDavid 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.

Correct - and it's not a significant problem if you're dealing with the external measurements of a solid. However, both sides of the holes are also reduced by the radius of the sphere - the calculations just get too complicated. But really the compilation time is the major issue when you have more than 1 hole in the object.]]>

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 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.]]>

Thanks! :)]]>

Darn that is a good way to do it!!]]>

Here my approach, which is a bit different. Instead of subtracting cylinders to get the chamfer, I construct the cylinder in slices:

// 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]]); }

The module

Here some more simple examples to show the basic working of the module

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:

]]>

Quote

**Dust**

My code is freeware! do with it what you wish, no strings attached.

My code is freeware! do with it what you wish, no strings attached.

Thank you! If I do create a library then you will be credited in the header... :)-D]]>

I've been trying to develop my own idea, and here's how far I've got:

[attachment 112788 Screenshotat2019-09-2612-50-13.png]

UPDATE 1: I've just look at the code written by 'Dust' - mine follows a similar technique. I didn't copy yours, honest!

UPDATE 2: Dust's approach is better than mine...

Obviously it doesn't yet achieve my original objective, but it's a start. I won't show the code just yet as it's messy and horrible, but I do plan to make it into a library so I'll put it up here for review when it's in decent shape (and when I'm not too ashamed to show it in public!).

Cheers,

David]]>

I hadn't thought about using minkowski when the object has the slots - in the real project I had applied it to the body prior to 'cutting' the slots. I shall have to try that out. However it means re-arranging my code as I have included screw holes in the same part as the slots (not a major crisis).

My other random thought last night was about making the slot itself a better shape - making the cube and two cylinders with 'fat ends' so that a difference with a larger object results in a rounded exit. I suspect that's what the code example is doing, but I'll confirm that later today...

Thanks for all your help - I'll see how it works out.]]>

minkowski() { difference() { cube(bodyWidth); translate( [bodyWidth/2, -1, bodyWidth/2] ) slot(); } sphere(1); }]]>

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);]]>

That is a rounded chamfer, and is very annoying do in openscad. (This is one of openscads biggest issues in my view)

You need to apply the chamfer to each component part, ie two cylinders and the square.

What I do is a 45 degree chamfer. Ie create some 90 degree cones at each end and remove how much you want

Do the same on the straight parts with a 45 degree rotated cube.

This is much easier to print, you don't get overhangs over 45 degrees.]]>

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(); }

This results in a cube with an oval hole through it (see attachment)

What I would like to do is to put a nice rounded edge around the hole at both ends. The trouble is, I don't know where to start! I would appreciate it if someone could give me some suggested techniques, helpful hints, etc. I'm not expecting anyone to actually do the work - just give me a clue about how to do it!

Note - this is something I've often wanted to do, but shied away from due to a lack of knowledge.

TIA,

David]]>