# How to close a pipe with a perfect hemisphere?

I have a sort of pipe shape which I want to close with a perfectly proportional hemisphere. Problem is the pipe does not have a perfectly round cross-section. It is a little squashed, but still I need to close it with a nice proportional ideal hemisphere. Is it possible?

I tried to pull the middle vertex out with proportional editing, using smooth or inverse square falloff but the result is bad. I also tried to fit a hemisphere, and attach it to the end of the pipe, but the pipe is not a perfect circle.

Using the bevel tool is a simple way to do this. First remove all of the edge loops on the endcap so you just have a single n-gon like this:

Note that I scaled the cylinder to give it an elliptical profile and skewed the face so that it is not perpendicular to the axis of the cylinder. I did this because this is how it appears to me in your picture. If you make your endcap perpendicular to the profile axis you will get a cleaner (more spherical) result.

Be that as it may, I used the Bevel tool which is located in the menu: Mesh > Edges > Bevel with the settings shown on the bottom left of the following image:

Using 8 segments achieves a well rounded result, although as I previously mentioned, the dome shape is distorted because of the angle of the face in respect to axis of the profile. I found that the "Depth" setting worked the best in this situation because I was able to extend the bevel very close to the convergence point without getting overlap. You may want to experiment with the settings to get what you want.

Addendum: Just to clarify what I mean about getting a cleaner, more spherical result by making the end cap perpendicular to the profile axis, here is a comparison:

• Exactly the effect I'm looking for. Very flexible solution too. Sep 20 '15 at 14:46
• LOL, my answer seems like using a chainsaw to cut a sheet of paper in comparison to this elegant fix, nice! Sep 20 '15 at 14:55
• Glad this worked for you. That's hilarious TLousky :) I appreciate the compliment. I'm a machinist, and I too am sometimes guilty of attacking a problem with brute force when a simpler solution has not yet presented itself. Sep 21 '15 at 1:48

If you don't need a really perfect hemisphere, you can simply use the root or sphere proportional editing falloff types.

But if you really do, then follow these steps:

1. Delete all the faces at the tip of your pipe, and fill the tip with one ngon face.

2. Select the outer edge ring in the tip of your pipe, then use the looptools --> circle tool to make this loop a perfect circle ( W --> looptools --> Circle). If you don't have the looptools available, activate the addons from the user preferences).

3. Open a text editor window and paste the following script there. It will calculate the angle of the face from the face normal.

'''
Run This script after you selected the face that should be
replaced with a hemisphere (in Edit Mode of course).
we'll use its normal to align the hemisphere.
'''

import bpy, bmesh
from mathutils import Vector
from math import degrees

bm = bmesh.from_edit_mesh( bpy.context.object.data )
normal = bm.faces.active.normal.copy()

upVec = Vector( [0,0,1] )

rot = upVec.rotation_difference( normal ).to_euler()

print( "Type this into the rotation values of your hemisphere object to align with the face")
print( [ degrees(a) for a in rot ] )

4. Open a system console (Window --> Toggle System Console) to see the script's output.

5. Select the ngon face at the tip of the pipe and run the script (press the "Run Script" button in the text editor window).

6. Check the number of vertices your pipe has and use it to create a UV sphere object with the same number of segments.

7. Cut the sphere in half by deleting the lower verts / faces.

8. Copy the angles specified in your system console to the XYZ rotation values for your hemisphere (bottom two lines in the image below).

9. Select the pipe again and snap the 3D cursor to the center of your ngon (Shift + S --> Cursor to Selected).

10. Select the hemisphere, then snap it to the 3D cursor (Shift + S --> Selection to Cursor).

11. Join the pipe and hemisphere (Ctrl + J), delete the ngon you created earlier, then select the two edge loops at the tip of the pipe and start of the hemisphere, then use the looptools bridge tool to join them (W --> Looptools --> Bridge).

• This is a very handy method. Good to keep in one's toolbox. However for some reason the rotations are inaccurate. It didn't match. Also for some reason LoopTools won't make a perfect circle out of the ending. It shifts only very slightly, though I tried various settings. Sep 20 '15 at 14:45

I would do like this:

1. Select the end face(s)
2. ShiftS > Cursor to selected
3. ShiftNumPad 7 (Align view to faces)