Finding a point within the proximity of another

I’ve been trying a few things but so far no luck. Please take a look at this, then I will explain what I’m trying to do:

See how those highlighted points are close to each other? I’m trying to find a way with Python scripting to give me a warning message if 2 points are found to be close to each other. I would like to be able to define the acceptable distance and any points found close to each other (closer than the distance I defined) will be flagged.

Any suggestions? I’ll keep plugging away at this but I’m definitely open to suggestions.

Thanks,

Dan

HI Dan,
Maybe something like this? - it’s a bit of a neanderthal hack, but you get the idea…

import rhinoscriptsyntax as rs

def FindPtsTooClose():
    atol=rs.UnitAbsoluteTolerance()
    min_dist=rs.GetReal("Minimum distance to select points?",atol,atol)
    if min_dist is None: return
    pt_objs=rs.ObjectsByType(1,state=1)
    if not pt_objs: return
    
    found=set()
    pts=[rs.coerce3dpoint(pt_obj) for pt_obj in pt_objs] 
    for i in range(len(pt_objs)):
        for j in range(i+1,len(pt_objs)):
            if pts[i].DistanceTo(pts[j])<=min_dist:
                found.add(pt_objs[i])
                found.add(pt_objs[j])
    if found: rs.SelectObjects(found)
FindPtsTooClose()
2 Likes

Hi Mitch,

Yes, this will be very helpful.

Thanks,

Dan