Welcome! Log In Create A New Profile

Advanced

How do you round the top and bottom of a tube?

Posted by appjaws1 
How do you round the top and bottom of a tube?
February 15, 2015 11:25AM
I have a tube with a wall thickness of say 4 mm and instead of straight edges top and bottom, I would like to round them, similar to the rounded cube and triangle but of course the inside and outside of the tube needs to be rounded.

I have tried searching for information on how to do this but I just can't find anything that is relevant and everything I try fails.

It also struck me that I may well have a use for the inverse of this in the future, whereby a cylinder is cut out of an object and I would like to have a rounded edge to the cut.

Any help much appreciated


appjaws - Core XYUV Duet Ethernet Duex5
firmware 3.1.1 Web Interface 3.1.1
Ormerod 1-converted to laser engraver, Duet wifi
OpenSCAD version 2020.07
slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1
Re: How do you round the top and bottom of a tube?
February 15, 2015 05:08PM
Why couldn't you just union a cylinder and a couple of spheres of the same radius at each end. For the interior, you could just make another of the same shape but with a smaller diameter, and subtract it from the first.
Re: How do you round the top and bottom of a tube?
February 16, 2015 04:56AM
Do you mean rounding the lip, or the entire end of the cylinder like an ibuprofen capsule?

If the former, then you have to think about the basic shapes that you are able to make and how you can stitch them together. A hollow tube with rounded ends is essentially two thin donuts bridged by a hollow tube. That description should make it obvious but here's an example:

$fn=100;		// reduce this for printing

Rounded_tube(100, 20, 5);

module Rounded_tube(height, radius, wall_thickness)
{
	ff = 0.05;		// CSG fudge factor

	// upper toroidal lip
	translate([0, 0, height/2-wall_thickness])
		rotate_extrude()
			translate([radius-wall_thickness/2, 0, 0])
				circle(d=wall_thickness);

	// lower toroidal lip
	translate([0, 0, wall_thickness-height/2])
		rotate_extrude()
			translate([radius-wall_thickness/2, 0, 0])
				circle(d=wall_thickness);

	// bridge it with a tube
	difference()
	{
		cylinder(h=height-2*wall_thickness, r=radius, center=true);
		cylinder(h=height, r=radius-wall_thickness, center=true);
	}
}

which looks like this:


Again, if you were to print this then you probably want to replace the lower toroid with one made from a teardrop.
Re: How do you round the top and bottom of a tube?
February 16, 2015 05:14AM
Similarly, if you want to define that shape that you'd use to cut a round hole with bevelled edges out of another solid, then you can use the same technique I described for your cube but using toroids to chamfer the edges:

$fn = 100;

Rounded_hole(100, 30, 5);

module Rounded_hole(depth, radius, bevel_radius)
{
	difference()
	{
		cylinder(h=depth, r=radius+bevel_radius, center=true);

		//elongated torus
		rotate_extrude()
			hull()
			{
				translate([radius+bevel_radius, depth/2-bevel_radius, 0]) circle(r=bevel_radius);
				translate([radius+bevel_radius, bevel_radius-depth/2, 0]) circle(r=bevel_radius);
			}
	}
}

Thus:


You'll have to adjust accordingly for CSG fudge factors, teardrops, etc. ;-)
Re: How do you round the top and bottom of a tube?
February 16, 2015 07:36AM
@QuackingPlums

Thank you for the examples.

I did eventually find a way to do it yesterday but it was very slow to render, your solution renders very quickly and produces a good result.

I really appreciate all the help you have given me


appjaws - Core XYUV Duet Ethernet Duex5
firmware 3.1.1 Web Interface 3.1.1
Ormerod 1-converted to laser engraver, Duet wifi
OpenSCAD version 2020.07
slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1
Re: How do you round the top and bottom of a tube?
February 17, 2015 01:08PM
I have been experimenting with various shapes and modules and have come across a problem that I just don't have the maths for.

This is an extension of the rounded end to a tube.

If I had a 5 mm thick tapered tube of say top diameter of 20 and bottom diameter of 15, how do I work out the placement of the top and bottom rings so that the outside and inside of the tube line up with the outside and inside of the circles whilst maintaining the overall height of say 30?
I've tried various methods and think I need to factor in tangents of the wall thickness somehow, but I'm not sure how.

any help greatly appreciated.


appjaws - Core XYUV Duet Ethernet Duex5
firmware 3.1.1 Web Interface 3.1.1
Ormerod 1-converted to laser engraver, Duet wifi
OpenSCAD version 2020.07
slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1
Re: How do you round the top and bottom of a tube?
February 18, 2015 05:13AM


$fn = 100;
t = 5;
td = 20;
bd = 15;
h = 30;

difference()
{
	cylinder(r1=bd, r2=td, h=h, center=true);
	cylinder(r1=bd-t, r2=td-t, h=h+0.01, center=true);
}

translate([0,0,h/2])
    color("green")
        torus(td, t/2, h);

translate([0,0,-h/2])
    color("blue")
        torus(bd, t/2, h);

module torus(d, r, h)
{
    rotate_extrude()
    {
        translate([d-r,0,0])
            circle(r = r);
    }
}

You mean like this?

Edited 1 time(s). Last edit at 02/18/2015 05:16AM by rhmorrison.


Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: How do you round the top and bottom of a tube?
February 18, 2015 05:28AM
BTW in the last post I didn't show the answer to:
Quote
appjaws1
whilst maintaining the overall height of say 30?

The two torus both have a radius of t/2 so together that is a height ot t (5 mm in your example)
so instead of
h = 30;
use:
h = 30 - t;


Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: How do you round the top and bottom of a tube?
February 18, 2015 05:36AM
Isn't that what I did Bob? ;-)

I like the gridlines - is that a feature in one of the newer dev branches?
Re: How do you round the top and bottom of a tube?
February 18, 2015 07:20AM
Thank you rhmorrison and QuackingPlums for your patience and understanding.

As a result of posts this week I now have a collection of modules that I can use for all kinds of rounded profiles.

However, it has been mentioned that for lower rounding I would be better off using a teardrop profile. I assume that a teardrop is constructed from a cube and a cylinder but how do I decide on the measurements for it compared to the normal circle radius that up to now we have used?
I would think that this line would be no good now and circle(r) would need to be change to something else ---but what to---?
rotate_extrude() {
translate([d-r,0,0]) circle(r = r);
}

again, any help greatly appreciated.
Paul


appjaws - Core XYUV Duet Ethernet Duex5
firmware 3.1.1 Web Interface 3.1.1
Ormerod 1-converted to laser engraver, Duet wifi
OpenSCAD version 2020.07
slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1
Re: How do you round the top and bottom of a tube?
February 18, 2015 08:34AM
Quote
QuackingPlums
Isn't that what I did Bob? ;-)

YES, in fact - you DID (but I forgot it in my first post)!

Quote
appjaws1
I assume that a teardrop is constructed from a cube and a cylinder

YES, or a circle and a rotated square that is created with rotate_extrude() or linear_extrude().


Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: How do you round the top and bottom of a tube?
February 18, 2015 08:50AM
$fn = 100;
t = 5;
td = 20;
bd = 15;
h = 30 - t/2 - sqrt(2)*t/2;

difference()
{
    cylinder(r1=bd, r2=td, h=h, center=true);
    cylinder(r1=bd-t, r2=td-t, h=h+0.01, center=true);
}

translate([0,0,h/2])
    color("green")
        torus(td, t/2, h);

translate([0,0,-h/2])
    color("blue")
        tearus(bd, t/2, h);

module torus(d, r, h)
{
    rotate_extrude()
    {
        translate([d-r,0,0])
            circle(r = r);
    }
}

module tearus(d, r, h)
{
    rotate_extrude(convexity=10)
    {
        translate([d-r,0,0])
        union()
        {
            circle(r);
            rotate(-135)
                square(size=r,center=false);
        }
    }
}


Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: How do you round the top and bottom of a tube?
February 18, 2015 09:40AM
Re: How do you round the top and bottom of a tube?
February 18, 2015 12:53PM
Well what a great forum this is.

Thank you all, for your kind responses, I have learnt a lot.


appjaws - Core XYUV Duet Ethernet Duex5
firmware 3.1.1 Web Interface 3.1.1
Ormerod 1-converted to laser engraver, Duet wifi
OpenSCAD version 2020.07
slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1
Re: How do you round the top and bottom of a tube?
May 10, 2015 05:00AM
i know it's probably a little late , to do pipe shapes i have some relatively painless code i wrote a while ago:

$fn=127;

diameter = 10;// outerdiameter
india=5; // innerdiameter
length=20; // overall length

rad=diameter-india;
offset=diameter/2-rad/4;
union(){
translate([0,0,rad/4])rotate_extrude()translate([offset,0,0])circle(r=rad/4);
#translate([0,0,length-rad/4])rotate_extrude()translate([offset,0,0])circle(r=rad/4);

difference(){
translate([0,0,rad/4])cylinder(r=diameter/2,h=length-rad/4-rad/4);
translate([0,0,1])cylinder(r=india/2,h=length);//  if you don't want the hole in the middle then remove this line
}
}




-=( blog )=- -=( thingiverse )=- -=( 3Dindustries )=- -=( Aluhotend - mostly metal hotend)=--=( Facebook )=-



Re: How do you round the top and bottom of a tube?
May 10, 2015 08:15AM
@thejollygrimreaper
Thanks for that, just shows many ways to achieve the same result


appjaws - Core XYUV Duet Ethernet Duex5
firmware 3.1.1 Web Interface 3.1.1
Ormerod 1-converted to laser engraver, Duet wifi
OpenSCAD version 2020.07
slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1
Re: How do you round the top and bottom of a tube?
May 23, 2015 03:28AM
translate([0,0,rad/4])rotate_extrude()translate([offset,0,0])circle(r=rad/4);

I love it, how we have to read from right to left, to understand, what´s going on grinning smiley

Or in other cases, "from bottom up"
-Olaf
Re: How do you round the top and bottom of a tube?
May 23, 2015 07:57AM
Quote
o_lampe
translate([0,0,rad/4])rotate_extrude()translate([offset,0,0])circle(r=rad/4);

I love it, how we have to read from right to left, to understand, what´s going on grinning smiley

Or in other cases, "from bottom up"
-Olaf

lol,




-=( blog )=- -=( thingiverse )=- -=( 3Dindustries )=- -=( Aluhotend - mostly metal hotend)=--=( Facebook )=-



Sorry, only registered users may post in this forum.

Click here to login