Hi All… and thank you all.

Eureka … well sort of.

I used Mitch’s suggestion to create the x,y,z values only, do all the math first using a pythagorean distance checker. Then add the good points… works fast.

My remaining problem is, sometimes the script fails. I believe it fails when there is no more room for another point…maybe?

In any case, if anyone has some error checking advice I would certainly welcome that,

code here…

\

python

```
import rhinoscriptsyntax as rs
import _random as rnd
import math
def RandPtsCloseChck():
npoints = rs.GetInteger("How many points? ", 200, 5, 1000)
l = rs.GetReal(" In Units, what is the square or cubic range? (500 is the limit) ", 40, 1, 500)
lmt = rs.GetReal("In units, what is the closest any 2 points can be?", 2.0, 0.1, 10.0)
r = (rnd.Random())
count = 0
pvlist = []
while count < npoints:
RandPointVals(l, pvlist, r, lmt)
count = len(pvlist)
MakePointsFromList(pvlist)
def RandPointVals(u, list, r, lmt):
pvx = u*r.random()
pvy = u*r.random()
pvz = u*r.random()
listval = [pvx,pvy,pvz] #create a list of values
list.append(listval) #nested list
if len(list) >= 2: CheckLastWithAll(list, lmt) #send to the checker
def CheckLastWithAll(list, lmt): # compares the last to all previous
junklist = []
chkvala = list[len(list)-1]
for i in range (len(list)-2):
chkvalb = list[i]
dist = PythValChk( chkvala, chkvalb)
if dist < lmt:
junk = list.pop()
junklist.append(junk) # trashcan
def PythValChk( new, chk ): #pythagorean distance checker
xdif = (new[0] - chk[0])
ydif = (new[1] - chk[1])
zdif = (new[2] - chk[2])
xydist = math.sqrt((xdif**2) + (ydif**2))
dist = math.sqrt((xydist**2) + (zdif**2))
return dist
def MakePointsFromList(list): # point maker
for j in range(len(list)):
x = list[j][0]
y = list[j][1]
z = list[j][2]
rs.AddPoint((x,y,z))
if __name__=="__main__":
RandPtsCloseChck()
```

\\