# Points distribution in surface

Hi there,
I am trying to create a bunch of point, equally separated (like a grid) on a surface. Firstly I create the surface, then I subtract lots of solids from it, so at the end I have a surface with lots of “holes”. After that I want to have a distribution of points that are inside the remaining surface.
I thought about creating these points in a big area (bigger than the whole surface) and then getting only those that intersect this surface, however this is getting my running too slow. I was wondering if anyone has any idea of how could I have those points without having to create all of them and then getting those which have intersection with the surface, something like creating points only where the surface exists, so I dont have to create so much points and then remove them.
Another problem is that I have lots of surfaces in a list, so each of them are in different places at the drawing so I must create these points at certains areas of the CoordinateSystem.
I don’t know if I could be clear on my explaining, so I’ve screen printed an example of how I am doing it now, so you can understand better what I want to have at the end. Any help would be appreciated.

Thanks!

Like this?

This is a better image.

Actually, this is exactly what I am trying to avoid… In your method, I would still have to create plenty of points that are going to be discarded, almost the same as mine, and that is slowing down the running process.

Thanks anyway!

I can’t think of another method to do this. If you create the points and check them for intersection in a single code line it shouldn’t slow you down too much.

I was thinking about something that could “split” a surface on a defined number of points maybe… I will try to optimize what I am doing now.
Thanks

Would a UV grid be helpful here or are you trying to get the same grid regardless of the surface shape?

I don’t really know which node is that, but it seems to be a great thing… Can you explain more? I cannot find it here!

@ricardoperucci Here is a distribution, not equally separated, but doesn’t create points beyond the surface
SurfacePoints.dyn (8.5 KB)

1 Like

That is closer to what I wanted to do! Thank you all for your replies, but I am doing it by creating a rectangular distribution of points (a rectangle that contains the whole surface) and then projecting them on the surface, all inside python. Doing it this way is actually not slowing down my running that much.
Thanks!!

This is what I’ve written, not sure if anyone are going to understand, but just for sharing…
My script uses a class instance that I’ve created before, “objetoDesenho”. From there I get some specific points, vectors, dimensions and list of objects to compare for this script specifically…

Blockquote

objetoDesenho= IN[0]
alturaRetangulo = IN[1]
folgaLateral = IN[2]
alturaPoligonoPosicao = IN[3]

listaPontos = []
listaPontosSaida = []

``````	ponto1Central = Point.Add(objetoDesenho.pontoTexto, Vector.Scale(Vector.Reverse(objetoDesenho.vetorDireita()), folgaLateral))

ponto3Ret = Point.Add(ponto4Ret, Vector.Scale(objetoDesenho.vetorDireita(), (2*folgaLateral + objetoDesenho.tamanhoTexto)))
ponto1Ret = Point.Add(ponto2Ret, Vector.Scale(Vector.Reverse(objetoDesenho.vetorDireita()), (2*folgaLateral + objetoDesenho.tamanhoTexto)))

retanguloInteiro = Rectangle.ByCornerPoints(ponto1Ret, ponto2Ret, ponto3Ret, ponto4Ret)
superficieRetangulo = Surface.ByPatch(retanguloInteiro)
solidoObjetoDesenho = Surface.Thicken(objetoDesenho.superficie(), 1)
superficieRetangulo = Surface.SubtractFrom(superficieRetangulo, solidoObjetoDesenho)[0]

#REMOVER AS SUPERFICIES DOS OBJETOS PERTOS E DOS LABELS POSICIONADOS

k = len(objetoDesenho.listaObjetoPerto) - 1
while k >= 0 and contador < 300:

objetoOutro = objetoDesenho.listaObjetoPerto[k]

solidoObjeto = Surface.Thicken(Surface.ByPatch(objetoOutro.polyCurve), 1)
superficieRetangulo = Surface.SubtractFrom(superficieRetangulo, solidoObjeto)[0]

solidoTexto = Surface.Thicken(Surface.ByPatch(objetoOutro.poligonoTexto), 1)
solidoPosicao = Surface.Thicken(Surface.ByPatch(objetoOutro.poligonoPosicao), 1)

superficieRetangulo = Surface.SubtractFrom(superficieRetangulo, solidoTexto)[0]
superficieRetangulo = Surface.SubtractFrom(superficieRetangulo, solidoPosicao)[0]

k = k - 1

vetorCS = Vector.Cross(objetoDesenho.vetorDireita(), vetorZN)
if Vector.Dot(vetorCS, objetoDesenho.vetorDesvioLabel()) < 0:

vetorCS = Vector.Reverse(vetorCS)

objetoCS = CoordinateSystem.ByOriginVectors(pontoOrigemCS, objetoDesenho.vetorDireita(), vetorCS)

x0 = 0
y0 = objetoDesenho.alturaTexto + 0.5*alturaPoligonoPosicao

xf = 0.5*objetoDesenho.tamanhoTexto + folgaLateral
yf = 0.5*(alturaRetangulo)

x = x0

while x < xf and contador < 2000:

if contador % 2 == 0:

else:

y = y0
while y < yf and contador2 < 2000:

xN0 = x0
yN0 = - 0.5*alturaPoligonoPosicao

xNf = xf
yNf = - yf

x = xN0

while x < xNf and contador3 < 2000:

if contador3 % 2 == 0:

else:

y = yN0
while y > yNf and contador4 < 2000:

for ponto in listaPontos:

pontoSaida = Geometry.Transform(ponto, objetoCS)
pontoSaida = Point.ByCoordinates(pontoSaida.X, pontoSaida.Y, 10)

projecao = pontoSaida.Project(superficieRetangulo, vetorZN)

if len(projecao) == 1:

You could use Surface.PointAtParameter to do this

SurfacePoints1.dyn (11.4 KB)

Nice!

1 Like

agents:
generate points via agents which move on the surface and pick the directions they move based on past information (where are we failing to find intersections)

divide and conquer:
split the surface into subsurfaces and apply points to these smaller portions, this could be multithreaded potentially.