2
$\begingroup$

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):

enter image description here

My definition of "reasonably efficient" is "more efficient than my current procedure", which is:

  1. Add a Bezier curve and modify it as desired.
  2. Under Object Data Properties, set the curve's Depth to the desired radius R and its Resolution such that the desired side count C is obtained (e.g., a resolution of 2 gives 8 sides).
  3. Convert the curve into a mesh (I'll refer to this as the tube mesh).
  4. Add a UV sphere with C segments, C rings, and a radius of R.
  5. Delete the bottom half of the UV sphere, leaving a hemisphere.
  6. 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.)
  7. Select the hemisphere and perform the Align to Transform Orientation operation with "End of tube 1" as the target orientation.
  8. Select the edge loop at one end of the tube mesh and perform the Cursor to Selected operation.
  9. Select the hemisphere and perform the Selection to Cursor operation.
  10. 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.)
  11. 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.
  12. 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): enter image description here

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.

$\endgroup$
2

1 Answer 1

5
$\begingroup$

Maybe, instead of the native curve bevel, you can use Array and Curve modifiers on a profile segment ..(blue section, below)

enter image description here

The array can have 'Start' and 'End' caps (red and yellow). It's easier to use Constant Offset in the array. Adjust (here, in Z,) the positions of the caps in Edit Mode, until the 'Merge' in the array takes, before giving the array a Curve modifier.

You can set the count of the array to fit the curve, and parent the curve to the mesh to keep it all together.

This is reasonably reusable, the curve and array can be duplicated together, and the curve edited as you like, the caps will stay in place.

If / When you want to fix the mesh, you can Header > Object > Convert To > Mesh, which will apply all the modifiers at once.

$\endgroup$
4
  • $\begingroup$ This is such a clever idea! :). $\endgroup$ Commented Mar 15, 2020 at 9:15
  • 1
    $\begingroup$ I like this approach, particularly the control over the resolution of the resulting mesh. However, ensuring the length of the swept profile segment exactly matches the length of the curve is difficult. One can measure the length L of the curve (using the Curve Tools addon), choose the desired segment count N along the curve, make the length of the profile segment L/N, and use "Fixed Count" set to N in the Array modifier, but unless the curve is a straight line the swept profile won't be as long as the curve. $\endgroup$ Commented Mar 15, 2020 at 19:44
  • 1
    $\begingroup$ Unfortunately the Array modifier's "Fit Curve" option overshoots the length of the curve (e.g., see this question) and I don't think there's an option to clip the last profile segment if it exceeds the length of the curve. $\endgroup$ Commented Mar 15, 2020 at 19:46
  • 1
    $\begingroup$ @ReignofError Got you.. I hadn't figured on that sort of CAD-like precision. You've got me looking thoroughly at the add-on.. $\endgroup$
    – Robin Betts
    Commented Mar 15, 2020 at 19:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .