Can anyone think of a way to get a tree of data where each branch is the points of each layer of a 3d grid, starting with the outer layer and working inwards.

Assuming an odd number of points in X,Y,Z so there is a line of points in the centre.

3dGrid.gh (6.9 KB)

Oh, and is there a better way of creating the initial grid?

In this model, the **line of points in the center** comes from `Set Difference`, the bottom component in the green group. All other points are in branches from `Cull Pattern`, the top component in the green group.

3dGrid_2019Jul24a.gh (25.8 KB)

P.S. It turns out that there can be a plane (grid) of points in the middle, not just a line.

Instead of X, Y and Z dimensions of the `ArrBox` cell (spacing) all being the same, this version allows them to be different. *(green-blue group)*

3dGrid_2019Jul24b.gh (31.3 KB)

P.P.S. Third time’s the charm?

I was able to avoid the `Set Difference` remainder by adding a “fudge factor” *(yellow group)* to prevent the condition of having a “Linear Box”, which `Brep CP` doesn’t like. `Max` ensures that the innermost box will have minimum dimensions of 0.001 instead of zero, so avoids having the last “branch” in a separate tree. Added the nested box edges for visualization purposes only.

3dGrid_2019Jul24c.gh (28.6 KB)

Thanks Joseph.

So basically create boxes where each layer will be and use BREP CP to get the points on each layer using CULL PATTERN

Good solution.

Yep. The concentric boxes are all centered on the `Avr` *(Average)* point of the 3D grid. Its X, Y and Z coordinates are half the X, Y and Z dimensions of the 3D grid and used as the ‘S’ *(Start)* input to `Series`, which counts down in increments of ‘Xcell’, ‘Ycell’ and ‘Zcell’, respectively.

The number of concentric boxes is determined in the cyan group *(below, not grouped in the code I posted),* which sorts the ‘X Count’, ‘Y Count’ and ‘Z Count’ values to find the smallest one, then takes half of it.

It turns out that you don’t need to use ‘Odd numbers’ for ‘X Count’, ‘Y Count’ and ‘Z Count’. Those sliders can have ‘Slider type’ set to ‘Integers’. Even numbers may result in the smallest box encompassing a 3D grid of points instead of a plane (2D grid) or line.