pETER!
I’m honoured. I’ve never even ridden a Ducati. 'A long time appreciater of your work
What a typically elegant and self - contained approach! thank you for your time and brainhorsepower, i see how it works. nice.
My hunch that to solve the issue mathematically “properly” (way past what I need to automagically mark-up a foundation detail) it requires a recursive approach (like yours has) with the addition of a fitness value.
Consider a situation where a bunch of points looking for a home are clustered around a single node (the last chair in a game of musical chairs), elsewhere nodes are available, but the closest ones to this cluster also have points near to them.
So a ripple out from this cluster is needed… pushing all the points out until those in the cluster find the nearest homes and those around the surrounding nodes are gently shooed out to their next nearest points as their spots are filled.
This was what kangaroo could easily do, but there’s clearly a scripted solution.
Psuedo script (stuck in foundations of a house right now, but will give it a go at some point, in python or sometimes VB sorry I know C# is your metalhorse of choice)
1 Add cumulative total distance from each homeless point to every node in the target grid -
Easy with components (closest points to the length of the target grid, mass addition of the distances)
(sluggish i know) - this gives a ‘fitness value’ for each homeless point- the smaller the number the more embedded in the nodes the point is. slider in the file below scrubs through the points ordered in this way
snap to closest point without duplicates_V003.gh (54.3 KB)
2 The fittest point is given to its closest node in the target grid. This node is removed from the target grid
3 The next fittest point takes its closest node, that node is eliminated, repeat until all points are home
(ideally a component to do this would have an input for the homeless points, one for the target grid, with either or both able to take data trees, and an index output for synchronous sorting of data alongside the transformed points).
Watch this space, as you say… Improving!
keep fighting the good fight. life doesn’t suck all the time… though it is all the time, all we have. And what an All.
R