discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

bend a pipe/tube

B
biskero
Wed, Apr 29, 2015 8:08 AM

Hello,

new here and glad to join!
I read several posts about bending a pipe/tube but are pretty old so I
wanted to know if there is a library or function that can achieve it.

I am trying to bend/curve a oval tube/pipe (made with cylinder) for a
certain % of the length.
I read about using the Torus and attach the tube to it, is this the only
method?

thanks
Alessandro

--
View this message in context: http://forum.openscad.org/bend-a-pipe-tube-tp12503.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hello, new here and glad to join! I read several posts about bending a pipe/tube but are pretty old so I wanted to know if there is a library or function that can achieve it. I am trying to bend/curve a oval tube/pipe (made with cylinder) for a certain % of the length. I read about using the Torus and attach the tube to it, is this the only method? thanks Alessandro -- View this message in context: http://forum.openscad.org/bend-a-pipe-tube-tp12503.html Sent from the OpenSCAD mailing list archive at Nabble.com.
CL
Chow Loong Jin
Wed, Apr 29, 2015 8:24 AM

On Wed, Apr 29, 2015 at 01:08:37AM -0700, biskero wrote:

Hello,

new here and glad to join!
I read several posts about bending a pipe/tube but are pretty old so I
wanted to know if there is a library or function that can achieve it.

I am trying to bend/curve a oval tube/pipe (made with cylinder) for a
certain % of the length.
I read about using the Torus and attach the tube to it, is this the only
method?

Check the sweep() demos in this:
https://github.com/openscad/list-comprehension-demos

--
Kind regards,
Loong Jin

On Wed, Apr 29, 2015 at 01:08:37AM -0700, biskero wrote: > Hello, > > new here and glad to join! > I read several posts about bending a pipe/tube but are pretty old so I > wanted to know if there is a library or function that can achieve it. > > I am trying to bend/curve a oval tube/pipe (made with cylinder) for a > certain % of the length. > I read about using the Torus and attach the tube to it, is this the only > method? Check the sweep() demos in this: https://github.com/openscad/list-comprehension-demos -- Kind regards, Loong Jin
B
biskero
Wed, Apr 29, 2015 8:32 AM

Ciao,

thanks for the link.
Any suggestions on which function would apply to my case?
I am kind of new to openscad and it will help me a lot.

Thanks
Alessandro

--
View this message in context: http://forum.openscad.org/bend-a-pipe-tube-tp12503p12506.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Ciao, thanks for the link. Any suggestions on which function would apply to my case? I am kind of new to openscad and it will help me a lot. Thanks Alessandro -- View this message in context: http://forum.openscad.org/bend-a-pipe-tube-tp12503p12506.html Sent from the OpenSCAD mailing list archive at Nabble.com.
CL
Chow Loong Jin
Wed, Apr 29, 2015 9:20 AM

On Wed, Apr 29, 2015 at 01:32:58AM -0700, biskero wrote:

Ciao,

thanks for the link.
Any suggestions on which function would apply to my case?
I am kind of new to openscad and it will help me a lot.

sweep(), basically. sweep() has this signature:

sweep(shape, path_transforms, closed=false);

shape is a list of 2D coordinates in a specific order. You can generate these by
using one of the functions in <scad-utils/shapes.scad>. These coordinates can also
be fed into polygon() to see what kind of shape you're getting.

path_transforms is a list of 4x4 matrix transformations that are applied using
multmatrix. Again, you can generate these individual transformations from
functions in <scad-utils/transformations.scad>. Each of these transformations
are applied to the coordinates in shape to get their current position, and then
joined to their previous operation.

Transformations from <scad-utils/transformations.scad> are basically functions
(translation, rotation, and scaling) that are analogous to the standard
rotate(), translate() and scale() operations in OpenSCAD. These all generate 4x4
matrices representing the operation. These matrices can be multiplied together
to combine them in a similar order to how OpenSCAD works.

closed is a boolean value defining whether or not you want your shape to be a
closed loop. A rubber band is a closed loop, a string is open-ended.

Here's an example:

sweep (circle (10, $fn = 20), [translation ([0, 0, 0]), translation ([0, 0, 20])]);

which is equivalent to:

linear_extrude (height = 20)
circle (r = 10, $fn = 20);

or

hull () {
translate ([0, 0, 0])
cylinder (r = 10, h = 0, $fn = 20);

   translate ([0, 0, 20])
   cylinder (r = 10, h = 0, $fn = 20);

}

Note that the last implementation won't actually work because you can't have a
cylinder with 0 height, but that's essentially what a circle is.

--
Kind regards,
Loong Jin

On Wed, Apr 29, 2015 at 01:32:58AM -0700, biskero wrote: > Ciao, > > thanks for the link. > Any suggestions on which function would apply to my case? > I am kind of new to openscad and it will help me a lot. sweep(), basically. sweep() has this signature: sweep(shape, path_transforms, closed=false); shape is a list of 2D coordinates in a specific order. You can generate these by using one of the functions in <scad-utils/shapes.scad>. These coordinates can also be fed into polygon() to see what kind of shape you're getting. path_transforms is a list of 4x4 matrix transformations that are applied using multmatrix. Again, you can generate these individual transformations from functions in <scad-utils/transformations.scad>. Each of these transformations are applied to the coordinates in shape to get their current position, and then joined to their previous operation. Transformations from <scad-utils/transformations.scad> are basically functions (translation, rotation, and scaling) that are analogous to the standard rotate(), translate() and scale() operations in OpenSCAD. These all generate 4x4 matrices representing the operation. These matrices can be multiplied together to combine them in a similar order to how OpenSCAD works. closed is a boolean value defining whether or not you want your shape to be a closed loop. A rubber band is a closed loop, a string is open-ended. Here's an example: sweep (circle (10, $fn = 20), [translation ([0, 0, 0]), translation ([0, 0, 20])]); which is equivalent to: linear_extrude (height = 20) circle (r = 10, $fn = 20); or hull () { translate ([0, 0, 0]) cylinder (r = 10, h = 0, $fn = 20); translate ([0, 0, 20]) cylinder (r = 10, h = 0, $fn = 20); } Note that the last implementation won't actually work because you can't have a cylinder with 0 height, but that's essentially what a circle is. -- Kind regards, Loong Jin
CL
Chow Loong Jin
Wed, Apr 29, 2015 9:25 AM

On Wed, Apr
29, 2015 at 05:20:56PM +0800, Chow Loong Jin wrote:

On Wed, Apr 29, 2015 at 01:32:58AM -0700, biskero wrote:

Ciao,

thanks for the link.
Any suggestions on which function would apply to my case?
I am kind of new to openscad and it will help me a lot.

sweep(), basically. sweep() has this signature:

 sweep(shape, path_transforms, closed=false);

shape is a list of 2D coordinates in a specific order. You can generate these by
using one of the functions in <scad-utils/shapes.scad>. These coordinates can also
be fed into polygon() to see what kind of shape you're getting.

path_transforms is a list of 4x4 matrix transformations that are applied using
multmatrix. Again, you can generate these individual transformations from
functions in <scad-utils/transformations.scad>. Each of these transformations
are applied to the coordinates in shape to get their current position, and then
joined to their previous operation.

Transformations from <scad-utils/transformations.scad> are basically functions
(translation, rotation, and scaling) that are analogous to the standard
rotate(), translate() and scale() operations in OpenSCAD. These all generate 4x4
matrices representing the operation. These matrices can be multiplied together
to combine them in a similar order to how OpenSCAD works.

closed is a boolean value defining whether or not you want your shape to be a
closed loop. A rubber band is a closed loop, a string is open-ended.

Here's an example:

sweep (circle (10, $fn = 20), [translation ([0, 0, 0]), translation ([0, 0, 20])]);

which is equivalent to:

linear_extrude (height = 20)
circle (r = 10, $fn = 20);

or

hull () {
    translate ([0, 0, 0])
    cylinder (r = 10, h = 0, $fn = 20);

    translate ([0, 0, 20])
    cylinder (r = 10, h = 0, $fn = 20);
}

Note that the last implementation won't actually work because you can't have a
cylinder with 0 height, but that's essentially what a circle is.

Oh, and here are two examples which are equivalent to help you understand how to
combine transformations:

rotate ([0, 0, 45])
translate ([10, 0, 0])
cube ([10, 10, 10]);

and

multmatrix (
rotation ([0, 0, 45]) *
translation ([10, 0, 0])
)
cube ([10, 10, 10]);

--
Kind regards,
Loong Jin

On Wed, Apr 29, 2015 at 05:20:56PM +0800, Chow Loong Jin wrote: > On Wed, Apr 29, 2015 at 01:32:58AM -0700, biskero wrote: > > Ciao, > > > > thanks for the link. > > Any suggestions on which function would apply to my case? > > I am kind of new to openscad and it will help me a lot. > > sweep(), basically. sweep() has this signature: > > sweep(shape, path_transforms, closed=false); > > shape is a list of 2D coordinates in a specific order. You can generate these by > using one of the functions in <scad-utils/shapes.scad>. These coordinates can also > be fed into polygon() to see what kind of shape you're getting. > > path_transforms is a list of 4x4 matrix transformations that are applied using > multmatrix. Again, you can generate these individual transformations from > functions in <scad-utils/transformations.scad>. Each of these transformations > are applied to the coordinates in shape to get their current position, and then > joined to their previous operation. > > Transformations from <scad-utils/transformations.scad> are basically functions > (translation, rotation, and scaling) that are analogous to the standard > rotate(), translate() and scale() operations in OpenSCAD. These all generate 4x4 > matrices representing the operation. These matrices can be multiplied together > to combine them in a similar order to how OpenSCAD works. > > closed is a boolean value defining whether or not you want your shape to be a > closed loop. A rubber band is a closed loop, a string is open-ended. > > > Here's an example: > > sweep (circle (10, $fn = 20), [translation ([0, 0, 0]), translation ([0, 0, 20])]); > > which is equivalent to: > > linear_extrude (height = 20) > circle (r = 10, $fn = 20); > > or > > hull () { > translate ([0, 0, 0]) > cylinder (r = 10, h = 0, $fn = 20); > > translate ([0, 0, 20]) > cylinder (r = 10, h = 0, $fn = 20); > } > > Note that the last implementation won't actually work because you can't have a > cylinder with 0 height, but that's essentially what a circle is. Oh, and here are two examples which are equivalent to help you understand how to combine transformations: rotate ([0, 0, 45]) translate ([10, 0, 0]) cube ([10, 10, 10]); and multmatrix ( rotation ([0, 0, 45]) * translation ([10, 0, 0]) ) cube ([10, 10, 10]); -- Kind regards, Loong Jin
B
biskero
Wed, Apr 29, 2015 9:57 AM

Ciao,

thanks a lot for the tips.
I am playing with your examples.

From what I understand everything starts from 2D shapes.

But I wanted to do it with a cylinder (in my case is a tube of oval section)
and apply a curve/bend at certain point to have one section straight and
rest shaped with that curve/bend.

Alessandro

--
View this message in context: http://forum.openscad.org/bend-a-pipe-tube-tp12503p12509.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Ciao, thanks a lot for the tips. I am playing with your examples. >From what I understand everything starts from 2D shapes. But I wanted to do it with a cylinder (in my case is a tube of oval section) and apply a curve/bend at certain point to have one section straight and rest shaped with that curve/bend. Alessandro -- View this message in context: http://forum.openscad.org/bend-a-pipe-tube-tp12503p12509.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MK
Marius Kintel
Wed, Apr 29, 2015 2:31 PM

On Apr 29, 2015, at 05:57 AM, biskero biskero@gmail.com wrote:

But I wanted to do it with a cylinder (in my case is a tube of oval section)
and apply a curve/bend at certain point to have one section straight and
rest shaped with that curve/bend.

There was a very similar feature request for this a while back:
https://github.com/openscad/openscad/issues/815

This is not something we’re working on right now, but if you have any ideas to contribute to that discussion, it would help us deciding exactly what features are needed when we eventually decide to implement it.

The alternative right now is to start from 2D. The toothed belt example provides an easy mechanism for describing paths:
https://github.com/openscad/list-comprehension-demos#toothed-beltscad

If you decide to go that way, it would be very helpful if you could describe what you’re doing and why - that would help us create better helper tools for allowing people to design similar objects. ..and even include a demo based on your work and experiences.

-Marius

On Apr 29, 2015, at 05:57 AM, biskero <biskero@gmail.com> wrote: > But I wanted to do it with a cylinder (in my case is a tube of oval section) > and apply a curve/bend at certain point to have one section straight and > rest shaped with that curve/bend. > There was a very similar feature request for this a while back: https://github.com/openscad/openscad/issues/815 This is not something we’re working on right now, but if you have any ideas to contribute to that discussion, it would help us deciding exactly what features are needed when we eventually decide to implement it. The alternative right now is to start from 2D. The toothed belt example provides an easy mechanism for describing paths: https://github.com/openscad/list-comprehension-demos#toothed-beltscad If you decide to go that way, it would be very helpful if you could describe what you’re doing and why - that would help us create better helper tools for allowing people to design similar objects. ..and even include a demo based on your work and experiences. -Marius
B
biskero
Wed, Apr 29, 2015 2:39 PM

Ciao,

yes I read that is basically what I was looking for.
It would be a great feature since you can simply tell a 3D object to follow
a direction into space to take shape.

At the moment I found a way to create an 2D ellipse and create an object
around a torus but is a pain and pretty slow process.

I just started to use OpenSCAD so not sure I can contribute with code, but
will provide feedback in here for sure.

I am working on a 3D printed project with some cool technologies, here some
infos:  hackebike http://twitter.com/hackebike

Alessandro

--
View this message in context: http://forum.openscad.org/bend-a-pipe-tube-tp12503p12512.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Ciao, yes I read that is basically what I was looking for. It would be a great feature since you can simply tell a 3D object to follow a direction into space to take shape. At the moment I found a way to create an 2D ellipse and create an object around a torus but is a pain and pretty slow process. I just started to use OpenSCAD so not sure I can contribute with code, but will provide feedback in here for sure. I am working on a 3D printed project with some cool technologies, here some infos: hackebike <http://twitter.com/hackebike> Alessandro -- View this message in context: http://forum.openscad.org/bend-a-pipe-tube-tp12503p12512.html Sent from the OpenSCAD mailing list archive at Nabble.com.
B
biskero
Wed, Apr 29, 2015 2:50 PM

Ciao,

here is code I found to create a ellipse tube based on torus, but it's
pretty slow when I compile it into my design, OpenSCAD starts thinking!!! :)
Any suggestion how to speed this code?

module torusSlice(r1, r2, start_angle, end_angle, convexity=10, r3=0,
$fn=64) {
rx = r1 + r2;
ry = rx;
trx = rx* sqrt(2) + 1;
try = ry* sqrt(2) + 1;
a0 = (4 * start_angle + 0 * end_angle) / 4;
a1 = (3 * start_angle + 1 * end_angle) / 4;
a2 = (2 * start_angle + 2 * end_angle) / 4;
a3 = (1 * start_angle + 3 * end_angle) / 4;
a4 = (0 * start_angle + 4 * end_angle) / 4;
if(end_angle > start_angle)
intersection() {
rotate_extrude(convexity=convexity) translate([50,0,0]) difference() {
//circle(r2, $fn=$fn/4);
//circle(r3, $fn=$fn/4);
ellipse(r2,1.44r2);
ellipse(r3,1.44
r3);
}

		translate([0,0,-r2-1])
		linear_extrude(height=2*r2+2)
    		polygon([
	            [0,0],
	            [trx * cos(a0), try * sin(a0)],
	            [trx * cos(a1), try * sin(a1)],
	            [trx * cos(a2), try * sin(a2)],
	            [trx * cos(a3), try * sin(a3)],
	            [trx * cos(a4), try * sin(a4)],
	            [0,0]
	       ]);
}

}
//ellipse(50,75);

module ellipse(width, height) {
scale([1, height/width, 1]) circle(r=width/2);
}

torusSlice(r1=10, r2=72, r3=67, start_angle=0, end_angle=25, $fn=60);

Thanks
Alessandro

--
View this message in context: http://forum.openscad.org/bend-a-pipe-tube-tp12503p12513.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Ciao, here is code I found to create a ellipse tube based on torus, but it's pretty slow when I compile it into my design, OpenSCAD starts thinking!!! :) Any suggestion how to speed this code? module torusSlice(r1, r2, start_angle, end_angle, convexity=10, r3=0, $fn=64) { rx = r1 + r2; ry = rx; trx = rx* sqrt(2) + 1; try = ry* sqrt(2) + 1; a0 = (4 * start_angle + 0 * end_angle) / 4; a1 = (3 * start_angle + 1 * end_angle) / 4; a2 = (2 * start_angle + 2 * end_angle) / 4; a3 = (1 * start_angle + 3 * end_angle) / 4; a4 = (0 * start_angle + 4 * end_angle) / 4; if(end_angle > start_angle) intersection() { rotate_extrude(convexity=convexity) translate([50,0,0]) difference() { //circle(r2, $fn=$fn/4); //circle(r3, $fn=$fn/4); ellipse(r2,1.44*r2); ellipse(r3,1.44*r3); } translate([0,0,-r2-1]) linear_extrude(height=2*r2+2) polygon([ [0,0], [trx * cos(a0), try * sin(a0)], [trx * cos(a1), try * sin(a1)], [trx * cos(a2), try * sin(a2)], [trx * cos(a3), try * sin(a3)], [trx * cos(a4), try * sin(a4)], [0,0] ]); } } //ellipse(50,75); module ellipse(width, height) { scale([1, height/width, 1]) circle(r=width/2); } torusSlice(r1=10, r2=72, r3=67, start_angle=0, end_angle=25, $fn=60); Thanks Alessandro -- View this message in context: http://forum.openscad.org/bend-a-pipe-tube-tp12503p12513.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MK
Marius Kintel
Wed, Apr 29, 2015 2:57 PM

On Apr 29, 2015, at 10:50 AM, biskero biskero@gmail.com wrote:

here is code I found to create a ellipse tube based on torus, but it's
pretty slow when I compile it into my design, OpenSCAD starts thinking!!! :)
Any suggestion how to speed this code?

The final render takes about 10 seconds. That’s normal, and you only do that once you’re done and want to export and STL.
Previews should be instantaneous.

-Marius

On Apr 29, 2015, at 10:50 AM, biskero <biskero@gmail.com> wrote: > > here is code I found to create a ellipse tube based on torus, but it's > pretty slow when I compile it into my design, OpenSCAD starts thinking!!! :) > Any suggestion how to speed this code? > The final render takes about 10 seconds. That’s normal, and you only do that once you’re done and want to export and STL. Previews should be instantaneous. -Marius