Openscad - curved cylinders
March 20, 2013 03:39PM
Does anybody know if it's possible to make curved cylinders in Openscad?

I'm trying to make a hollow right angle tube for connecting plastic pipe, and although I can hollow out something in pieces, it would be much smoother if I could just use Difference() and remove a single cylinder that was bent into 90 degrees.
Re: Openscad - curved cylinders
March 20, 2013 04:33PM
Regular circular curved cylinders? Just rotate_extrude a circle and make a difference with slightly smaller circle, also rotate_extruded. Then cut this further with difference if you want just a 90 degree segment.
Re: Openscad - curved cylinders
March 20, 2013 05:04PM
ttsalo Wrote:
-------------------------------------------------------
> Regular circular curved cylinders? Just
> rotate_extrude a circle and make a difference with
> slightly smaller circle, also rotate_extruded.
> Then cut this further with difference if you want
> just a 90 degree segment.

Thanks,

This kind of works, but I'm getting this donut shape that doesn't straighten out at the ends, so no pipe could fit inside the openings. I'm looking to make the smooth right angle, but not a circle. Still it's closer than anything else I've tried.
Re: Openscad - curved cylinders
March 20, 2013 05:31PM
Something like this?

union(){
	difference(){
		rotate_extrude(120) translate ([50,0,0]) circle(10);
		difference(){
			cube([120,120,40], center = true);
			translate([30,30,0]) cube([60,60,40], center = true);	
			}
		rotate_extrude(120) translate ([50,0,0]) circle(8);
		difference(){
			cube([120,120,40], center = true);
			translate([30,30,0]) cube([60,60,40], center = true);	
		}
	}
	difference(){
		translate([50,0,0]) rotate([90,0,0]) cylinder(r=10,h=20);
		translate([50,0,0]) rotate([90,0,0]) cylinder(r=8,h=22);
	}
	difference(){
		translate([0,50,0]) rotate([0,270,0]) cylinder(r=10,h=20);
		translate([0,50,0]) rotate([0,270,0]) cylinder(r=8,h=22);
	}	
}
Re: Openscad - curved cylinders
March 20, 2013 05:38PM
you could use hull operator between to sphere

module pipe(l,r) {
    assign(distance=l-2*r) {
        hull() {
            translate([0,0,0])
            sphere(r=r);
            translate([0,0,distance])
            sphere(r=r);
        }
    }
}



union() {
    pipe(l=20, r=5);
    rotate([90,0,0])
    pipe(l=20, r=5);
}
Re: Openscad - curved cylinders
March 20, 2013 06:05PM
Andrew Smith Wrote:
-------------------------------------------------------
> Something like this?
>
>
> union(){
> difference(){
> rotate_extrude(120) translate ([50,0,0])
> circle(10);
> difference(){
> cube([120,120,40], center = true);
> translate([30,30,0]) cube([60,60,40], center =
> true);
> }
> rotate_extrude(120) translate ([50,0,0])
> circle(8);
> difference(){
> cube([120,120,40], center = true);
> translate([30,30,0]) cube([60,60,40], center =
> true);
> }
> }
> difference(){
> translate([50,0,0]) rotate([90,0,0])
> cylinder(r=10,h=20);
> translate([50,0,0]) rotate([90,0,0])
> cylinder(r=8,h=22);
> }
> difference(){
> translate([0,50,0]) rotate([0,270,0])
> cylinder(r=10,h=20);
> translate([0,50,0]) rotate([0,270,0])
> cylinder(r=8,h=22);
> }
> }
>

Thanks Andrew, this would work, but I made something like this last night and it couldn't print the thin walls without it distorting from the heat. So, I decided that I'd make a box with a shape like what you've created, that would not be hollowed, and would be subtracted from the cube. I also made the cube with a flat spot to mount it. I can deduct simple cylinders, but the inside ends up jagged and I would like it smooth so that water can flow through unobstructed. Your design is the right shape, but it is hollow, and I can figure out how to put it inside my box and subtract it. Here is my box, if it helps you to see what I'm trying to do. The tube I'm putting into the holes is 22 mm.

$fn=20;

difference()

{


//Main Cube
cube (size = [50,50,30]);

//Small cube for mounting flat
translate (v=[30,30,5])
cube (size = [22,22,32]);

//Mounting hole
translate (v=[40,40,-2])
cylinder(h = 10, r=3);


}

Thanks,
Jon
Re: Openscad - curved cylinders
March 20, 2013 06:18PM
Gerard Choinka Wrote:
-------------------------------------------------------
> you could use hull operator between to sphere
>
>
> module pipe(l,r) {
> assign(distance=l-2*r) {
> hull() {
> translate([0,0,0])
> sphere(r=r);
> translate([0,0,distance])
> sphere(r=r);
> }
> }
> }


This might work if I could subtract it from my box...

$fn=20;

difference()

{


//Main Cube
cube (size = [50,50,30]);

//Small cube for mounting flat
translate (v=[30,30,5])
cube (size = [22,22,32]);

//Mounting hole
translate (v=[40,40,-2])
cylinder(h = 10, r=3);


}

Thanks,
Jon

>
>
>
> union() {
> pipe(l=20, r=5);
> rotate([90,0,0])
> pipe(l=20, r=5);
> }
Re: Openscad - curved cylinders
March 20, 2013 06:19PM
difference(){
union(){
cylinder(r=15,h=60);
translate([0,0,30])rotate([0,90,0])cylinder(r=15,h=60);
}

translate([0,0,-1])cylinder(r=13,h=62);
translate([0,0,30])rotate([0,90,0])cylinder(r=13,h=62);
}

//that will produce a 90degree pipe, you just have to add the flaring where needed,

for a much stronger version:

difference(){
hull(){ // comment this out to take out the smoothing
union(){
cylinder(r=15,h=60);
translate([0,0,30])rotate([0,90,0])cylinder(r=15,h=60);
} ///comment this out to take out the smoothing
}

translate([0,0,-1])cylinder(r=13,h=62);
translate([0,0,30])rotate([0,90,0])cylinder(r=13,h=62);
}




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



Re: Openscad - curved cylinders
March 20, 2013 09:22PM
thejollygrimreaper Wrote:
-------------------------------------------------------

> //that will produce a 90degree pipe, you just have
> to add the flaring where needed,




Thanks, but these are both T- junctions, and I'm trying to make just a right angle connector. I did make one similar to your first example by translating one pipe to the end and closing the other, but the turn is too sharp and creates resistance to the flow of the water and I'm trying to reduce that by having a smooth, curving turn instead of an abrupt one. I want to put it inside a box that will make it strong and easier to print, and also that has a built in mounting plate. Here is the box I'm trying to hollow out for the pipe, which is 22mm in diameter:


$fn=20;

difference()

{

//Main Cube
cube (size = [50,50,30]);

//Small cube for mounting flat
translate (v=[30,30,5])
cube (size = [22,22,32]);

//Mounting hole
translate (v=[40,40,-2])
cylinder(h = 10, r=3);

}
Re: Openscad - curved cylinders
March 20, 2013 09:55PM
$fn=20;


difference()

// this will create a torus and make a curved hole, it's a bit of a tight fit and the corner for the mounting part may need to move away from the tube a little bit but this should be closer

{

//Main Cube
cube (size = [50,50,30]);

//Small cube for mounting flat
translate (v=[30,30,5])
cube (size = [22,22,32]);

//Mounting hole
translate (v=[40,40,-2])
cylinder(h = 10, r=3);
translate([45,45,15])#rotate_extrude()translate([33,0,0])circle(r=11);
}




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



Re: Openscad - curved cylinders
March 21, 2013 01:51AM
thejollygrimreaper Wrote:
-------------------------------------------------------
> $fn=20;
>
>
> difference()
>
> // this will create a torus and make a curved
> hole, it's a bit of a tight fit and the corner for
> the mounting part may need to move away from the
> tube a little bit but this should be closer
>
> {
>
> //Main Cube
> cube (size = [50,50,30]);
>
> //Small cube for mounting flat
> translate (v=[30,30,5])
> cube (size = [22,22,32]);
>
> //Mounting hole
> translate (v=[40,40,-2])
> cylinder(h = 10, r=3);
> translate([45,45,15])#rotate_extrude()translate([3
> 3,0,0])circle(r=11);
> }

Wow!
That's exactly what I was trying to do smiling smiley
Tommorrow, I'll make the radius 10, and then insert a 22mm cylinder into each opening to straighten out the slight curve, and also to provide a recess for the tubes to hit when they are inserted. My garden and I really appreciate what you've done, and I will be assembling my irrigation system using this connector this weekend.

Jon
Re: Openscad - curved cylinders
March 21, 2013 02:42AM
Thanks to Thejollygrimreaper and Andrew Smith, I've got the finalized design. I'll try printing it tomorrow, as it is quite late where I am...

Here is the final design:

$fn=100;

difference()

{

//Main Cube
cube (size = [50,50,30]);

//Small cylinder for mounting flat
translate (v=[46,46,6])
cylinder(h = 30, r=18);

//Mounting hole
translate (v=[40,40,-2])
cylinder(h = 10, r=3);

//Small cylinder for mounting flat - outside
translate (v=[-2,-1,6])
cylinder(h = 30, r=18);

//Mounting hole
translate (v=[7,7,-2])
cylinder(h = 10, r=3);


//Taurus
translate([45,45,15])#rotate_extrude()translate([33,0,0])circle(r=9);

difference(){

translate([60,13,15]) rotate([0,270,0]) cylinder(h=22, r=11);

}

difference(){


translate([13,60,15]) rotate([90,270,0]) cylinder(h=22, r=11);
}

}
Re: Openscad - curved cylinders
March 21, 2013 07:32AM
it'll be interesting to see how it holds up with running water through it, not that i have small thinwall objects working really well i want to see how feasable it is to print things like pipe and tubing that can interlock and seal properly maybe even a printable pressure vessel?




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



Re: Openscad - curved cylinders
March 21, 2013 03:40PM
thejollygrimreaper Wrote:
-------------------------------------------------------
> it'll be interesting to see how it holds up with
> running water through it, not that i have small
> thinwall objects working really well i want to see
> how feasable it is to print things like pipe and
> tubing that can interlock and seal properly maybe
> even a printable pressure vessel?


I'm actually using them in two different irrigation applications, so I'll let you know how they work out. The first is at a community garden where I will be sourcing the water from a 45 gallon drum using gravity feed, so it won't have any real pressure to it. The other is inside my greenhouse and hooking it up to the mains.

I've attached photos - the first didn't finish because my computer stalled, but you can see inside how they look. The abomination in the photo was my original attempt to just make a connector like you'd get a hardware store. The heatbed distorted it pretty badly. The second photo shows a finished connector. Andrew Smith gave me the code to put the straight end in the openings and they fit perfectly snug. I plan on using ABS to PVC transition glue to attach them to the pipe. I made the taurus you provided 18mm in diameter to match the inside diameter of the pipe and there is no ridge between the pipe and the connector, as you can see in the cut away piece.

I printed the first piece at 80% fill with 5 walls thickness. When I cover one end and blow into the other, I think I can sense some air leaking out through the walls, but it may be my imagination, so I'm now printing one with 100% fill for the ones I'll be hooking up to the mains.

I kind of like that this connector can be mounted to anything I want, including stakes pushed into the ground to keep it just above the soil. You can't buy something like this at a hardware store for this price. Thanks again to you and Andrew for your collaboration in this design!

Jon
Attachments:
open | download - connector small 1.jpg (162.9 KB)
open | download - connector small 2.jpg (208.9 KB)
Re: Openscad - curved cylinders
March 21, 2013 06:35PM
what kind of glue are you using on them?

have you thought about printing a thread as well?




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



Re: Openscad - curved cylinders
March 22, 2013 01:41AM
thejollygrimreaper Wrote:
-------------------------------------------------------
> what kind of glue are you using on them?
>
> have you thought about printing a thread as well?

I'm using this cheap PVC pipe that sells for $2.14 for ten feet at Home Depot, It doesn't have threads, and I don't think threads could be cut into it because it's, well, cheap stuff. It's rated for 200 psi though. Home Depot sells this stuff called "transition glue" for gluing PVC to ABS. I haven't tried it yet, but I have no reason to believe it won't work. It would be nice to print threads into some of them though, because ultimately I have to connect to regular garden hose connectors and I haven't figured out how to do that yet. There are very cheap plastic valves that I'd like to connect to because they can regulate the pressure and flow somewhat. How would I incorporate threads into these? Does Openscad have things like standard garden hose threads built into it somewhere?
Re: Openscad - curved cylinders
March 22, 2013 09:44AM
Imo it is probably better to use `module` and variables more in the future? An example in the attachment.(The parameters there are wrong and you may want the mounting holes at some particular place)

Also, maybe instead of substracting a cylinder at the outside end of the torus, it is more efficient to intersect with a cylinder, or use a quarter cylinder as the 'base shape' to start from and then add the mounting plate, substract the torus and 'flangespace'. (and rounding) (That is assuming you want flat surfaces top and bottom.)

I am nitpicking a bit, i overly quickly made that example.
Attachments:
open | download - forum.scad (1.5 KB)
Re: Openscad - curved cylinders
March 22, 2013 04:42PM
Jasper1984 Wrote:
-------------------------------------------------------
> Imo it is probably better to use `module` and
> variables more in the future? An example in the
> attachment.(The parameters there are wrong and you
> may want the mounting holes at some particular
> place)
>
> Also, maybe instead of substracting a cylinder at
> the outside end of the torus, it is more efficient
> to intersect with a cylinder, or use a quarter
> cylinder as the 'base shape' to start from and
> then add the mounting plate, substract the torus
> and 'flangespace'. (and rounding) (That is
> assuming you want flat surfaces top and bottom.)
>
> I am nitpicking a bit, i overly quickly made that
> example.

Well, it looks like the same thing, but the code is quite different. I'm still very new at using Openscad, so I haven't a lot of experience with using modules and variables yet. Am I correct in believing that they are what you need to make the design parametric, and sizable just by changing a few values? If so, then I would like to understand how to do that. Meanwhile though, I'm happy with the simple design that is working for me now and I'm pumping out 6 to 8 per day. It is spring and time to be setting up the irrigation system, and I need the pieces now. I will look further into this, as I'm eager to learn how to program using conventions and protocols that keep things neat and tidy.

Thanks for your input.

Jon
Re: Openscad - curved cylinders
March 23, 2013 11:18AM
You are correct. Of course there is nothing wrong with just cooking something up that fits your needs!

Parameteric designs can be useful in applying on different cases later, or when some sizes change later, or when you havent figured out the sizes yet. You just change some values.

It comes fairly easily to me but not sure how difficult it is for regular people.. Basically you do some math and work step by step, looking at what you have at the point.

For instance here you first make the cut-out and then figure out the shape to cut it out from, if you have a cut like this: (with some arbitrary angle)

module bend_cut() //Used to cut out the bend.
{
    rotate_extrude() translate([bend_r,0])circle(r=tube_r);
    translate([bend_r,0]) rotate([90,0,0]) cylinder(r=flange_r, h = bend_r);
    //This one is just the other way, and then rotated around the vertical axis.
    rotate([0,0,angle]) translate([bend_r,0]) rotate([-90,0,0]) cylinder(r=flange_r, h = bend_r);
}
bend_cut();

You can for instance think of putting it in a cylinder, with the same center as the torus. The radius has to be `bend_r + flange_r + thickness`, (thickness is `plate_w` in the above attachment) Similarly the height must also have the extra thickness; `2*(flange_r+thickness)`. You can then substract another cylinder with a radius `bend_r - flange_r -thickness`... And then you need to cut off the 'pie piece' of that angle. And you'd need space for the flanges too! Writing in text is going to take rather long i suppose.(But maybe i can do it...)

> I will look further into this, as I'm eager to learn how to program using conventions and protocols that keep things neat and tidy.

Frankly I am not really satisfied with convenientions and protocols either! Havent seen much guidelines for that matter. Besides, we're using computers, say you make a bottle cap, there should be a way of describing saying it is a 'female screw' of such and such description so that the computer can just look at it and give out things compatible automatically. Also there doesnt seem to be a 'defaulting' system where people can enter parameters without changing the file. (Openscad good, but not that good, imma try coffeescad)
Re: Openscad - curved cylinders
April 13, 2013 04:01PM
Andrew_Smith, I'm looking at this code snippet from an early response:
rotate_extrude(120) translate ([50,0,0]) circle(10);

I'm guessing that the >120< refers to a portion of 360 degrees thru which to rotate. But when I try to use this syntax, I get an error that implies the >120< is being interpreted as a file name!

What version of OpenSCAD supports this syntax? I have used both the latest released version as well as the latest daily build. No joy.
Re: Openscad - curved cylinders
April 13, 2013 04:22PM
The 120 is actually the convexity parameter, which is the maximum number of faces any given ray through the object migth intersect. No idea why I had it set so high, leave it at the default 10. Not that it matters, since its only used in rendering the model, not in generating the .stl.

I'm using an older version of openscad, 2011.06, but the manual says its still supported. Post your code and the error messages you get.
Re: Openscad - curved cylinders
April 15, 2013 09:00AM
rotate_extrude(convexity=120) {
	translate ([50,0,0])
		circle(10);
}


Bob Morrison
W├Ârth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: Openscad - curved cylinders
April 17, 2013 12:06AM
Thanks for the prompt replies. The high value for convexity threw me off; using the syntax like rhmorrison shows works fine. However, what I was really hoping was that you could tell me how to (easily) get a portion of a cylinder by specifying the desired angle!

Oh well, I'll just do it the not-so-easy-way. That works.
Re: Openscad - curved cylinders
August 10, 2015 01:23PM
An old thread, but it came up in my search for how to do a 90 degree hollow pipe. I came across some incredibly complex code in the process, but reading this one it was the simplest but still not what I was looking for. Looking at the code I realised how simple this could be, so if anyone else is searching for how to create a 90 degree hollow pipe, here it is. If you want a solid one, just remove the second difference part, as this hollows the tube out.

$fn=100;

difference()
{
intersection()
{
translate([0,0,0])rotate_extrude()translate([33,0,0])circle(r=11);
translate([0,0,-25])cube ([50,50,50]);
}

intersection()
{
translate([0,0,0])rotate_extrude()translate([33,0,0])circle(r=8);
translate([0,0,-25])cube ([50,50,50]);
}

}
Re: Openscad - curved cylinders
August 10, 2015 02:22PM
Thanks for the info, Wibbles. smiling smiley
Re: Openscad - curved cylinders
August 11, 2015 10:28PM
There's another approach that some find more intuitive - draw the desired cross section in 2D, then extrude into 3D and clip to 90 degrees. Something like:

elbow(innerRadius=8, outerRadius=11, bendRadius=33);

module elbow(innerRadius, outerRadius, bendRadius)
{
 intersection()
 {
  rotate_extrude()
   translate([bendRadius, 0, 0]) 
    difference() 
    {
     circle(outerRadius);
     circle(innerRadius);
    }
  translate([0, 0, -outerRadius]) 
   cube([bendRadius + outerRadius, bendRadius + outerRadius, outerRadius*2]);
 }
}

Edited 1 time(s). Last edit at 08/11/2015 10:30PM by tray.
Re: Openscad - curved cylinders
August 12, 2015 06:21AM
If you're running the 2015.03 release or later and want arbitrary bend angles, this works better...
elbowinator(angle=135, bendRadius=33)
  wall2D(thickness=3)
    circle(r=8);

module wall2D(thickness)
  difference()
  {
    offset(thickness)
      children(0);
    children(0);
  }
 
module elbowinator(angle, bendRadius, clipBounds=1000, convexity=4)
  intersection(convexity=convexity)
  {
    rotate_extrude(convexity=convexity)
      translate([bendRadius,0,0])
        children(0);
    linear_extrude(height=clipBounds, slices=2, center=true)   
      wedge2D(angle, clipBounds);
  }

module wedge2D(angle, r, nSides=3) 
  polygon(points=concat([[0,0]], [for(i=[0:nSides]) r*[cos(i/nSides*angle), sin(i/nSides*angle)]]), convexity=4);
Sorry, only registered users may post in this forum.

Click here to login