# Geometry nodes: sampling Z position from curve to mesh

I have a mesh that I want to bend along the curve, then move all vertices to match its Z position. Here's the process:

1. Mesh in X length of the curve
2. Bend the mesh to curve on XY plane
3. Align mesh's Z positions to the curve, using the X position from step 1 for curve length sampling. And there's a problem - the mesh is not properly aligned with curve, depending on the angle it's too low or too high. I assume I have to correct the X length input for sampling, but I have no idea how to do this.

Edit: the blend with the case: https://blend-exchange.com/b/Pav9wL2L

• I need to bend an existing mesh Commented Jun 29, 2022 at 14:20
• However, the mesh you show here can be easily constructed with Geometry Nodes. Or is it actually a more complex mesh? Commented Jun 29, 2022 at 14:22
• It's complex mesh - I want to bend any input mesh possible, so I can't generate it from curve Commented Jun 29, 2022 at 14:23
• I don't understand the part about "bend Z positions". Can you explain this a bit more? Commented Jun 29, 2022 at 16:27
• @quellenform it's a 'Z Up' deformation I think.. One route: capture curve Z, flatten curve, deform mesh to flat curve, offset by captured Z. You or me? Commented Jun 29, 2022 at 16:47

I hope this is what you're after.. it's just an adaptation of the X Curve Deform group from here, which you say you are using, changing the mapping in the curve's coordinates.

• X to the position on the curve
• Y to the cross-product of the curve tangent with (0,0,1), flat to XY, at right-angles to the tangent
• Z to (0,0,1)

The new arrangement is shown below:

The result:

It would be simpler to adjust the tilt to make the curve 'Z Up'.. figuring that one out, unless @quellenform gets there first :)

You could take this futher in the mesh, by, for example, flattening the tops of the turrets to XY

• Well, @RobinBetts, you have taken the cake once again ;-) Commented Jun 29, 2022 at 18:24
• @quellenform Unless I can figure it, I'll post the 'Z-up' Q as one of my own.. just an invitation to have think about it :D Commented Jun 29, 2022 at 19:00
• It works well on the spiral, but on other curves it's getting misaligned image Commented Jun 29, 2022 at 19:05
• @UserNoRandomNumber See Edit Commented Jun 29, 2022 at 21:13