# Collecting attributes from vertices based on area and using in geometry nodes (for 3D graphs)

I have a high-level challenge I'm trying to work out, and feel I'm very close but missing some Geometry Nodes knowledge to get what I want out of it, and would really appreciate some help or direction.

The goal is to take an object consisting of a 'cloud' of unconnected vertices, each with a custom attribute value on them, and create a 3D graph that groups the points into a grid and assigns height based on this custom attribute, summed for each point in the grid square.

For some background I'm using this script to convert a csv file into the vertex cloud: https://blender.stackexchange.com/a/241870/76672

This is my starting point, with the custom attribute being 'scaleVec':

I can easily turn this into a bar chart by instancing cubes on each point and moving the bottom face, but the issue is the bars will often overlap, so I want to have a grid underneath that groups points near each other and shows the amount by summing the number of points, or the combined value of the attributes.

This is a top-down view showing an example point distribution over a small grid (3 points over the green square, 1 over the blue, 1 over the red, and none over the yellow):

and the expected result:

I have been trying to use Raycasting from the points downwards onto a grid in Geometry nodes, as well as the Attribute Statistic node to sum attributes, but I'm getting a bit stuck, and if anyone is up for giving me some pointers for this challenge (im using Blender 3.1) Id really appreciate :-)

Here is my solution (for demo reason, I distribute random points and weight is 1 everywhere):

How it works:

To sum all weights, I use accumulate field node. Coordinates of each point is rounded and x is multiplied by 10, so that I can get a unique ID of each square:

When I just set position to rounded one and instance cubes

Last step - remove duplicated points:

• Thanks, thats great, I have tried adding a value to control the resolution of the underlying grid, that has to affect the floor, positioning, cube size etc, I was wondering what is the value for the 'Multiply' node based on? is it 10 mainly because of the grid size that you set up to test or is it relative to the cube size, floor etc? Commented May 2, 2022 at 21:58
• It is just to give a unique number for each bar group. Each line contains 10 bars. Commented May 3, 2022 at 7:26

Following, I will explain two different solutions.

# Solution 1: Instantiate bars on points based on proximity to the instantiation point

This one is similar to the one of Crantisz, but works a litte different. Instead of calculating grid squares, it creates a grid and uses proximity functions:

It starts with setting the ID of each point in the cloud to the index of the nearest point in the target grid.

Next it sets the position of every point in the cloud to the nearest raster point and stores the count of points at this position directly at those points.

Finally it merges the points by distance and creates the bars in the appropriate size:

## Dynamic Version

And here is a dynamic version of solution 1:

# Solution 2: Extrude Faces based on proximity to face

This solution starts with some points on some faces. It then counts the points per face by proximity and extrudes the faces based on this count. You may plug in any object.

## How does it work?

It starts with creating points on the faces of the object, defined by the input parameters. Then it iterates over those points and calculates the number points per face index. This value is stored at every point by the Capture Attribute node together with the related face index in the ID of the point. Now every point knows, to which face it belongs and how many points belong to this face.

Finally, we would like to iterate over all faces and read the number of points from one of these points. We can do this by reading the captured attribute from the nearest point to the current face. But this will not work, if there is no point. In this case, we would get a foreign point instead of none.

To get around this, we place the points on the origin of their faces and merge them by distance:

Now we have zero or one point on the origin of every face. And the point knows, how many points belong to the face. This allows us to iterate over all faces and grab the point count from the nearest point to each face. If the distance to this point is greater than 0, this means, that there is no point. To prevent issues in some cases, we will have to check for > 0.001.

We use this value to define the scale of the extrusion of the related face.

• Thank you, I will try this one out too... would this technique work better (with modification) with an irregular sectioned plane (ie one split into quadrants, or triangles) instead of a grid? I had experimented with raycast in order to use this on such a shape as mathematical functions wouldn't work as well on it, perhaps i should formulate it into another question if its a large modification Commented May 2, 2022 at 22:17
• It depends on the shapes and on their regularity, because the points are assigned to the bars by their distance to the instantiation points. Anyway, I could imagine a similar solution, that could work. If I find some time, I will try tomorrow. Commented May 2, 2022 at 22:25
• @awnine, I added another solution to my description, that should work with every type of plane. Commented May 3, 2022 at 19:57