How to color mesh with custom value coresponding to X,Y,Z coordinates

Let’s say I have a simple mesh with points on it. I want to color this mesh according to a value coresponding to the X,Y,Z coordinates of this points. How can I do that? Basically it is like coloring the hight, but instead of hight we need to color another atribute. Namelly Cp value.

Thank you in advance!

Here’s a way to apply the colours based on the boundingbox of the mesh. I.e. the red, green, and blue components are normalised to always go from minimum to maximum.

xyz-rgb.gh (20.4 KB)

2 Likes

Here is a visual example of exactly what I want to do. I have a table with coordinates and corresponding values:
X Y Z Value
|-55.1234|43.4541|16.0733|0.656874|
|55.1221|43.4567|16.0738|0.429775|
|-56.2218|43.4781|16.0726|0.333916|
|56.2198|43.4768|16.0727|0.635001|
|58.3018|69.5851|15.3748|0.032365|
|-58.3015|69.5849|15.3748|-0.0997031|
|15.2787|43.5949|15.4692|0.814485|
|-15.2788|43.5949|15.4692|0.726578|
|-12.8615|43.592|15.846|0.934393|
|12.8613|43.5919|15.846|0.2255057|

someone need to create a new grasshopper forum in order to provide a platform for assisted thinking and selfless help. :wink:

2 Likes

That’s quite a different question, and will require a different solution.
mesh and colour.gh (25.2 KB)

2 Likes

Yes!!! Exactly. You are brilliant! Thank you so much for this!
The only thing that is left is to somehow extrapolate this onto the original mesh.

The values are derived trough a CFD software. This software re-meshed the original file. (There is no way around this re-meshing).

The mesh you posted contains 2887 vertices, the csv file you posted contains 2778 measurements. They cannot be matched up 1:1.

If they could, then you’ll have to use the Deconstruct Mesh component to get the vertices of your original mesh, then the Closest Point component to figure out which of the vertices in the mesh was closest to your parsed coordinate. You can then use the indices of this closest point search to sort your colours into the correct order and use Mesh colours once again to apply them.

1 Like

Actually it’s easier. Assuming you have a list of 2887 points + colours, you then useClosest Point the other way around and you can extract the correct colour directly using List Item. No sorting required.

1 Like

Can you demonstrate? I am lost here… I will try it in a couple of hours, when I am home.

The first step worked like magic :slight_smile:

Yes! This absolutely did the trick! And you are right, the point number have to be greater in the analysed mesh. My friend, you are brilliant! Thank you so much for your amazing help!

Final problem. I need to output in a Panel the Cp values for the original coordinates. After closest point, I am guessing that the points from my original mesh and the mesh from the analysis are paired. Now I just need the points from the analysed mesh to send the Cp values to the point of the original mesh.

You should only have a single mesh now, the one from the dxf file. You can use Closest Point to find which measurement in your csv file relates to each vertex. Whether you then use that index to get the associated colour, or whether you use it to get the associated value is the same operation. You just have to hook it up to the fourth output of the List Item component instead of the Gradient object.

You probably hate me by now. I can’t manage to do this step. I am almost done… Can you send a screenshot just of this part?

I don’t have a working mesh so I can’t test this, but I think this is what you’re after:

If the order of these values corresponds to the order of the vertices of the original mesh… Yes!!!