# Calculating variable length within instances in geometry nodes

I'm trying to create a geometry node setup that simulates dropping a bunch of objects from strings suspended from an overhead grid. The objects should stay in a fixed 200 x 200mm XY grid, but drop down to follow a surface that is curved. I would like each one to be "tied" to the overhead grid by a simple line curve (which I will later expand out into a simple cylinder mesh.)

My approach has been to create a grid, instance the hanging objects onto the points, then drop the objects down onto the guide surface using Raycast. This is working fine.

I then create a line curve orginating with the dropped objects.

This is where I run into problems: I have point A, and I know that point B should have the same (x,y) but an absolute/world Z value based on the original grid object. However, I cannot work out how to find/calculate/plug in the B point.

Any help or suggestions would be enormously appreciated.

Cheers Peter

## 1 Answer

If you start from the bottom you can just set the z component of all ends of curves to be on the same height:

and if you want a custom resolution/positioning, then just start by shrinkwrapping the plane of your choice onto the surface, and then proceed in the same way:

• Thanks Markus, this is awesome! Commented Aug 6 at 22:54
• This worked perfectly. Am I right in thinking that the 'realize instances' node is key? It that what allows me to get a real world position for each object that actually works? Commented Aug 6 at 23:15
• @user92557 the power of instances is that they reuse geometry. So those nodes that allow you to modify instances, modify the original geometry the instances reuse. Typically all your instances use the same original, and so all are synchronized - they need to have the same shape except for the scale. In this case you could actually avoid realizing instances because you could just differ the scale, but instances won't save you much resources (if any) for a simple curve line like that. Commented Aug 7 at 14:47