Point Proximity

This RhinoScript deletes points that are closer than a distance given by the user. I’ve used this script to modulate the density of a set of points used to generate a Delaunay mesh. I’ll be posting my script for Delaunay triangulation soon.

Option Explicit
‘Script written by <Ayodh Kamath>
‘Script copyrighted by <Ayodh Kamath>
‘Script version Wednesday, June 23, 2010 2:32:34 PM
Call Main()
Sub Main()
Dim dblProxDist, arrPts, strPt
Dim i, j
arrPts = Rhino.GetObjects(“Select points”,1)
If UBound(arrPts)>300 Then
Call Rhino.MessageBox(“The number of points selected is: “&CStr(UBound(arrPts))&”. Please re-run the script and select less than 300 points.”)
Exit Sub
End If
dblProxDist = Rhino.GetReal(“Enter minimum proximity distance:”)
For i = 0 To UBound(arrPts)
For j = 0 To UBound(arrPts)
If i<>j Then
If Rhino.IsObject(arrPts(i)) And Rhino.IsObject(arrPts(j)) Then
If Rhino.Distance(Rhino.PointCoordinates(arrPts(i)), Rhino.PointCoordinates(arrPts(j)))<dblProxDist Then Rhino.DeleteObject(arrPts(j))
End If
End If
Next
Next
End Sub
Advertisements

One thought on “Point Proximity

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s