I’m working on a gh script that distorts a grid of points by moving them around curves that are input by the user. The output is something like this:

Originally, my script did a sift pattern for points that fall on top of a surface (created by boundary curves input by user), this was determined if the distance to surface is 0.

Then, the points move to the nearest edge. It worked okay, but the results were less than desirable. The grid would still run through the boundary curves because some points would snap to the left edge of the boundary curve, and some would snap to the right.

So, I started finding the boundary edge (left or right of input curve) that was on average closest, for all the points in the branch(grid line). This worked well!

Until, one branch(grid line) intersects two different boundary curves. The average edge is thus determined by two discrepant boundary curves that should have nothing to do with each other.

So, the script becomes incredibly more complicated because now I am trying to dispatch different sub-lists of the points based on which boundary curve they fall within.

Keep in mind, the data needs to be recombined at the end such that the nurbs curves can be drawn through all the points in the grid line, whether they had to be moved or not. Also, keep in mind, there is an unknown quantity of input curves that could be input by the user, so I am trying to keep it as parametric as possible.

**My Failed Dispatch Method**

- I created a separate list of all the input curves for each point in the grid. I measured the distance to each curve. Then, I find the curve with the shortest distance to that point, and use a “member index” to make an index of which curve that point should be associated with.

- I find the points that all share the index of the same closest curve. Then, I find the indexes of these points in the original sifted list. Then, I use a “list item” to make a sub-list of the points.

You can see in the image below, I am trying to split branch 11 into sub branches {11;0} and {11;1}, based on which curve is closest. It is mostly working, but I am returning two “” values in branch {11;0}, and I don’t know why.

So, I am coming to the McNeel forum to ask what is wrong with my script? And is there a better way to go about doing this?

alterGridWithCurves04.gh (24.1 KB)