# How do I bend? Classic List Threaded 7 messages Open this post in threaded view
|

## How do I bend?

 Make a shape like a pipebend. ----- Thomas Leonard Gertz Kerteminde, Danmark -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org Thomas Leonard Gertz Kerteminde, Danmark
Open this post in threaded view
|

## Re: How do I bend?

Open this post in threaded view
|

## Re: How do I bend?

 In reply to this post by Thomas Leonard Gertz If you're feeling silly and have OpenSCAD 2015 or more recent, you can do something like this: ```function flatten(list) = [for (a=list) for (b=a) b]; module pipebend ( curve_radius=10, bend_angle=30, pipe_od=2, pipe_id=1.8, \$fn=36 ) { \$fbend=\$fn; \$fpipe=\$fn; or=pipe_od/2; ir=pipe_id/2; c_step=360/\$fpipe; b_steps=ceil(bend_angle/360*\$fbend); b_step=bend_angle/b_steps; opoints= flatten([for (theta=[0:b_step:bend_angle]) [for (phi=[c_step:c_step:360]) [ cos(theta) * (curve_radius+or*cos(phi)), sin(theta) * (curve_radius+or*cos(phi)), or*sin(phi) ] ] ]) ; ofaces=flatten([concat( [[for (i=[\$fpipe-1:-1:0]) i]], flatten([for (j=[0:b_steps]) [for (i=[\$fpipe-1:-1:0]) [j*\$fpipe+i,j*\$fpipe+(i+1)%\$fpipe,(j+1)*\$fpipe+(i+1)%\$fpipe,(j+1)*\$fpipe+i] ] ]), [[for (i=[\$fpipe:-1:0]) (\$fpipe*(b_steps+1))-i]] )]); ipoints= flatten([for (theta=[-b_step:b_step:bend_angle+b_step]) [for (phi=[c_step:c_step:360]) [ cos(theta) * (curve_radius+ir*cos(phi)), sin(theta) * (curve_radius+ir*cos(phi)), ir*sin(phi) ] ] ]) ; ifaces=flatten([concat( [[for (i=[\$fpipe-1:-1:0]) i]], flatten([for (j=[0:b_steps+2]) [for (i=[\$fpipe-1:-1:0]) [j*\$fpipe+i,j*\$fpipe+(i+1)%\$fpipe,(j+1)*\$fpipe+(i+1)%\$fpipe,(j+1)*\$fpipe+i] ] ]), [[for (i=[\$fpipe:-1:0]) (\$fpipe*(b_steps+3))-i]] )]); difference() { polyhedron( points=opoints, faces=ofaces ); polyhedron( points=ipoints, faces=ifaces ); } } pipebend(\$fn=36,bend_angle=45,curve_radius=5,pipe_od=5,pipe_id=4); ``` Sent from the OpenSCAD mailing list archive at Nabble.com._______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: How do I bend?

Open this post in threaded view
|