Seed Randomize

Hi Community

At the moment Im working on a python code, that allows me to place points in a randomize way, with some constraings of limitations along a surface, aint that complex, however i believe because of the size of the surface and the amount of iterations somethings is getting wrong.

If you have any advise on how to clean the code, I will appreciate it.

Im feeding the code with a list of vectors, a point and a surface

Enable Python support and load DesignScript library

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

import sys
py_path = r"C:\Program Files (x86)\IronPython 2.7\Lib"
sys.path.append(py_path)
import random
import math

The inputs to this node will be stored as a list in the IN variables.

surface = IN[0]
stPoint = IN[1]
vectors = IN[2]

#Funciones de soporte
def vector():
return random.choice(vectors)

def area_circ(circles):
all_circles =
for i in circles:
area = math.pi*(i.Radius**2)
all_circles.append(area)
return sum(all_circles)

Place your code below this line

def sembrado(surface,stPoint,cov=6):
puntos =
circles =
puntos.append(stPoint)
circles.append(Circle.ByCenterPointRadius(stPoint,(cov/2)-0.01))

area_surf = surface.Area
cuadricula = int(area_surf/(cov*cov))
perc = int((cuadricula*75)/100)

areas = area_circ(circles)

random.seed(2)
count = 0
while count < 10: #percentage
	move_pt = Geometry.Translate(random.choice(puntos),vector(),cov)
	if move_pt.DoesIntersect(surface) == True:
		create_cir = Circle.ByCenterPointRadius(move_pt,(cov/2)-0.01)
		temp = []
		for circle in circles:
			if create_cir.DoesIntersect(circle) == True:
				temp.append(0)
			if create_cir.DoesIntersect(circle) == False:
				temp.append(1)
		if len(set(temp)) == 1:
			puntos.append(move_pt)
			circles.append(create_cir)
			areas = area_circ(circles)
			count += 1
		if len(set(temp)) != 1:
			temp = []
			pass
	else:
		pass
	
return puntos, circles

Assign your output to the OUT variable.

OUT = sembrado(surface,stPoint)