Point grid within irregular curves

Hi everyone, I am trying to create a script which allows me to extract a series of points within irregular curves by inputting the amount of points (density). These need to be laid on a regular grid with fixed distances. Can anyone point me in the right direction please?

PLANTING.gh (10.6 KB)

PLANTING.3dm (176.5 KB)

Why not wire the A×B result to the SDivide ‘U’ and ‘V’ inputs?

that would give me 306 points along u AND along v, whereas I want 306 in total, equally spread on square grid.

image

Thanks Martin, this would work for this specific shape - I’m looking for a generic solution which could be applied to any curve.

The expression on both ‘U’ and ‘V’ inputs to SDivide is ‘x-1’.

PLANTING_2023Sep11a
PLANTING_2023Sep11a.gh (9.1 KB)

Whoa! Like what curves, for example?

P.S. This might be a circle-packing problem for Kangaroo?

1 Like

Thanks a lot Joseph - this works well. I’m not familiar with Kangaroo, so I’ll give it a look.
As the file title suggests, I am looking to apply this script to several planting beds, so that I can identify planting numbers quickly, then dispatch points and draw circles (plants) with different radii for different species.

Yeah, but without examples, we don’t know if they are all rectangular (where a different algorithm might work) or truly irregular as in the image I posted. In either case, circle-packing may be the best.

Thanks for your help - it will be a mix of rectangular and irregular shapes like the one you posted. So I imagine I could use either script depending on the shape.

I’ll say it again.

2 Likes

Circle-packing may not give you a square point grid, as your title suggests, but the points will be evenly spaced from each other. For rectangular plots that are not square, you don’t have a suitable algorithm yet, though I imagine it depends on the ratio of short side to long side somehow? For trapezoids like the one you posted, that pattern of points is not “a regular grid with fixed distances”. For truly irregular curves, all bets are off! I’m not saying it can’t be done but an entirely different approach is required.

2 Likes

Here is an approach that gives you a “proper” point grid, aligned with the longest edge (or a line that you supply - cyan group),. You define the space between columns and rows using a Rectangle component wired to the ‘C’ input of ArrRec. I used one slider for both dimensions (X & Y) so the grid is square, but it doesn’t have to be.

The ‘X’ and ‘Y’ count inputs to ArrRec are computed from the U and V dimensions of a Bounding Box, then InCurve and Cull Pattern are used to select only the grid points within the offset curve. Adjusting the rectangle dimensions affects the total - it’s not automatic.


PLANTING_2023Sep11b.gh (14.7 KB)

Your dimensions are HUGE :exclamation: Millimeters? One effect of such large dimension values is that it’s very difficult to see plane icons and their axes so it’s hard to tell how they are aligned.

P.S. The results depend too on where you start the grid, which is somewhat arbitrary. For example, do you really want a row or column with only one plant?

This might be useful?

The cyan group lets you choose among a set of test curves. I have four now, all roughly the same area and located at the origin. Index 0 is your trapezoid, 1 and 2 are the curve I posted and 3 is a square, The code looks for edges that are lines and chooses the longest one to initially align the plane. When no lines are found, alignment defaults to ‘World XY’.

In either case, the ‘Angle’ slider (blue group) allows rotation of the point grid ±180 degrees.


PLANTING_2023Sep11cc.gh (26.3 KB) … UPDATED (see below)

P.S. Oops, I just noticed an error. When separate sliders are used for Rectangle ‘X’ and ‘Y’ inputs, as I did in this case, the ‘Y’ slider must be connected to the ‘B’ input of the A/B component who’s ‘A’ input comes from the Dim ‘V’ output. A quick fix is to connect the ‘X’ slider to both ‘X’ and ‘Y’ inputs of Rectangle as before, making a square grid.

I think I’ll leave the flaw because it’s important to understand this part of the code, in case you want different separation for rows and columns in the point grid.

UPDATED: Added X_dim and Y_dim params to make the wiring less error prone.

PLANTING_2023Sep11ccc

1 Like

This is brilliant - many thanks for your help.

UPDATED post to make the wiring less error prone - added X_dim and Y_dim params. (see above)