(Using Blender 3.6.1 and Geometry Nodes)
Approach: Combine an Extrude Mesh node to create the volume, with a Raycast node to compute the length of extrusion up to a targeted object.
Documentation: About the Extrude Mesh Mode: Faces vs Edges vs Vertices
- Faces: The starting face is displaced such that its centre is on the targeted object. It remains parallel to its original orientation. So its vertices may not be on the targeted object, based on initial relative orientations between this object surface and the extruded face. Lateral faces are created also as surfaces swept by the extruded face edges. Only lateral faces at the boundaries of connected faces are created if the Individual input is false.
- Edges: The starting face edges are displaced such that these mid-points are on the targeted object. So vertices at both ends may not be on the targeted object. The starting face is not displaced. All lateral faces are created as surfaces swept by the extruded edges, even those between connected faces (NB: the Individual input is available only in Faces Mode).
- Vertices: The starting face vertices are displaced such that these lay on the targeted object. Lateral edges are created as lines swept by the extruded vertices. However, no lateral faces are created. The starting face is not displaced.
0. Initialization: Add a GeometryNodes modifier to the curve object.
1. Minimal extrusion: Add an Extrude Mesh node in Faces mode to create only lateral faces at the boundaries. Offset Scale is set to zero, because whatever this input, extruded faces would not lay on the targeted object.
2. Extrusion displacement computation: Add a Raycast node to find the position, on the targeted object, of the new Top vertices created by extrusion at step 1. The Target Geometry and Ray Direction inputs are collected from the Group Input node for flexibility. (NB1: The direction vector is defined in the object coordinate system, not in the world coordinate system. NB2: The displacement is based on the position of the targeted object relative to the curve object, not its original position).
3. Extrusion correction: Add a Set Position node to move on the targeted object the vertices created at step 1.
4. Geometry trimming: Add a Delete Geometry node with Face domain and Only Edges & Faces mode set, to remove the extruded faces (i.e. the Top) and to keep only the lateral faces. This will keep polycount minimal.
5. Normals correction: Based on the input Direction vector orientation relative to the original faces normals, the lateral faces normals might be pointing at the wrong side. if so, add a Flip Faces node. (NB: In Viewport Overlays, switch ON Geometry/Face Orientation to control).
6. Semi-closure: Add a Join Geometry node to fill the beginning of the extruded contour with the original faces.
7. Geometry trimming: Add a Merge by Distance node to seal the rim between both sets of faces, laterals and originals.