Given an arbitrary curve swept with a circular profile of a specific radius and side count (controlled using the Depth
and Resolution
parameters of the curve's Geometry
), is there a reasonably efficient way to add hemispherical caps of the same radius to each end of the swept curve to produce an arbitrarily curved capsule shape?
The desired result is the 3D equivalent of this (please see the Blender screenshot lower down as well):
My definition of "reasonably efficient" is "more efficient than my current procedure", which is:
- Add a Bezier curve and modify it as desired.
- Under
Object Data Properties
, set the curve'sDepth
to the desired radius R and itsResolution
such that the desired side count C is obtained (e.g., a resolution of 2 gives 8 sides). - Convert the curve into a mesh (I'll refer to this as the tube mesh).
- Add a UV sphere with C segments, C rings, and a radius of R.
- Delete the bottom half of the UV sphere, leaving a hemisphere.
- Select the edge loop at one end of the tube mesh, create a face, create a transform orientation named "End of tube 1" (for example), and delete the face. (Note that creating a transform orientation with the edge loop selected is not sufficient: the resulting transform orientation is based on the active edge only.)
- Select the hemisphere and perform the
Align to Transform Orientation
operation with "End of tube 1" as the target orientation. - Select the edge loop at one end of the tube mesh and perform the
Cursor to Selected
operation. - Select the hemisphere and perform the
Selection to Cursor
operation. - Rotate the hemisphere by an appropriate angle about the Z axis of the "End of tube 1" transform. For example, with C = 8, the angle is 22.5 degrees because 360 degrees/8 sides = 45 degrees per side, which is then divided by two since the hemisphere's rotation is off by half the angular extent of one side relative to the end of the tube.)
- Join the hemisphere to the tube, select all vertices, and merge
By Distance
. This removes the C duplicates where the hemisphere and the tube meet. - Repeat steps 4 through 11 to add a hemispherical cap to the other end of the tube.
Here's a screenshot of a blend file containing all the steps (from left to right along the global X axis; two empties mark steps 6 and 8, although only one is visible in the screenshot):
I'm hoping there's a quicker way to achieve the same result. I've tried using the bevel tool (as suggested in this answer), but it requires cleanup at the convergence point when the bevel distance is set to R.