Making Elbows with OpenSCAD

Making Elbows with OpenSCAD

thingiverse

This thing is not so much a model to print as an example of an improved solution to the problem of joining two cylinders right angles. The obvious way to do this would be to simply offset and rotate the two pipes and place a sphere at the joint with a sphere() function. However, when coded this way the facets will not line up. You can see this in the model at the left and in the zoomed of boundary between the cylinders and the sphere. The code for that approach in the function elbow_sphere() ``` module elbow_sphere() { sphere(1); rotate([180,0,0]) cylinder(2,1,1); rotate([-90,0,0]) cylinder(2,1,1); } ``` The problem happens even if the $fn numbers are the same for the cylinder and the sphere function. Of course, you can increase $fn and make it less noticeable, but at the cost of a much more complex .stl file when you render it. Alternatively, you can control how the facets are generated by using rotate_extrude() on a semi-circle and using that in place of the standard library sphere() like this: ``` module my_sphere(r) { rotate_extrude() difference() { circle(r); translate([0,-r,0]) square(2*r); } } ``` For simplicity, $fn is assumed to be defined globally but you could pass it in to better match the library sphere() function's signature. The other two models show the elbows formed with my_sphere() using two different orientations. The .stl file made using the sphere() function is about 72k in size while the other two are 40k and 43k respectively. To join pipes at angle other than 90 deg can be done by rotating the sphere so its axis is aligned with bend axis. The elbow2() function actually shows this for the 90 deg case. The $fn values must be a multiple of 4. In the minimal case of $fn=4, you get rectangular tubes. I think this also illustrates the problem with the library sphere() function. For $fn=4 you get an inscribed cube while the alternate function gives an octahedron. It occurred to me that this may be the one of the causes of slow rendering that came up on a recent question on the OpenSCAD group, so I thought I'd write up some details and share them here. Please let me know what you think, and thanks for looking, Bob M

Download Model from thingiverse

With this file you will be able to print Making Elbows with OpenSCAD with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on Making Elbows with OpenSCAD.