Snap mesh vertices within a distance

grasshopper
python
kangaroo
unhandled

(Altair0319) #1

This is a part of my generative algorithm and I’ve been stuck at here for a long time, hopefully someone can inspire me:

Assume I have created two mesh polygon, each has multiple vertex. The two mesh have different composition: they could one include another, intersect, touch, close or far away from each other. The thing I need to do is to pair every vertex of one mesh with a closest vertex from another nearby mesh, and within a set distance, the two vertex will snap together.

I know in kangaroo there’s magnet snap or coincident, but the problem is 1. vertex from same mesh cannot snap. 2. I have a lot of mesh to evaluate, around 50 or even more, each has around 150 vertex, it’s too much work to calculate every vertex and find it’s closest point from every other mesh.

maybe I’m thinking in a wrong way, if you can help me come out with a sufficient solution you will save my day…

I included my grasshopper file and a manual model, it’s not accurate, but at least can tell what I want to do.


test.gh (29.5 KB)
test.3dm (168.7 KB)


(Altair0319) #2

Anyone can help?


(Tim Stark) #3

I don‘t know if there‘s a way to find the closest point without calculating the distance to the other points. Maybe the script can be optimized. For example: First find the closest meshes and only calculate the distance to their verticies.