[github.com]

Sort of a fork of OpenSCAD, sort of a re-write.

Curious if folks tried it and gave up on it, and if so why --- if folks are using it, I'd like to discuss it a bit.]]>

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

$fn=180; difference(){ rotate_extrude(angle=3)translate([200,0,0])square([24,24]); for(a=[0,90])rotate(a) translate([-300,0,-1])cube([600,600,26]); translate([0,0,3])rotate_extrude(angle=3)translate([203,0,0])square([18,18]); }

]]>

only one radius.

So I just rotate extrude a square ? and than make it hollow ?

Thanks I will try.]]>

This one is composed of 3 sections with [angle,radius] pairs [20,200],[-25,450],[-180,150].

If you only have one section with a constant radius, you can just with a difference of two rotate_extrude(...)square(...).

]]>

What remains is a hollow square beam with a bend according the outer perimeter of the ball.

Now scale up the result to the dimensions of 6 lipo 18650 cells stacked upon each other along their long sides and put it in the box.

Does this help ?]]>

So that will be a beam shaped object. (subtract a cube from a cube will do the math)

However, the remaining box must be slightly curved to follow the shape of the drone landing gear, to which the boxes will be fixed.

Any help in bending a beam , of the resulting box ?

Thomas]]>

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

The code I had cobbled together was a combination of a part that I had made to replace rollers on my nieces futon and a 'sheriff's badge' I had found on Thingiverse. It got it started, and with enough tinkering, it probably could have been made to work, but I figured there had to be a better way to do it.]]>

I prefer diameters vs radius, and for holes I use a trick that doubles the height and lowers it by half the height. No need to randomly add heights

OutsideDiameter = 89 * 2; InsideDiameter = 19 *2; height = 10; HoleOD = 9*2; NumberOfHoles = 6; HoleDisatnceFromCenter = 37; $fn=128; difference () { cylinder(d=OutsideDiameter,h=height); translate([0,0,-height/2]) cylinder(d=InsideDiameter,h=height*2); for (i = [0:1:NumberOfHoles-1]) { rotate([0,0,i*360/NumberOfHoles]) translate([HoleDisatnceFromCenter,0,-height/2]) cylinder(d=HoleOD, h=height*2); } }]]>