the problem I am facing is the following:
I try to make a mesh slope analysis I got stuck at the point where I want to assign certain colors to a certain slope range. In pseudocode i imagine something like this:
for (int i = 0; i < angleList.Count-1; i++)
{
if (angleList[i] > V[i] & angleList[i] < V[i+1])
{
var color = C[i];
colorList.Add(color);
}
}
Do note that what you are trying to do won’t work the way you’re trying it. You can only assign colours to a mesh on a per-vertex basis. Whereas you’re computing the colours on a per-face basis. The number of faces and vertices are not the same, and the ordering is also not the same.
Instead, you should probably measure the VertexNormals.
I know this answer is a little off topic, but I thought I would share. We spent some time looking at a few approaches for this and the examples below seemed to be a good fit for us. Maybe it helps?
Another approach is to explode the mesh faces into individual meshes. This allows you to assign the same color to all the vertices of each resulting “face”, (resulting in “coloring by face”). Here is an example in python.
You can also do it with mostly native components. (need something to explode the mesh, this example uses UTO Mesh Edit tools, but you can write your own). The python implementation is literally a copy of what is going on in the file below. The python implementation also uses ghpythonlib.components ConsecutiveDomains and FindDomain, (they really do the heavy lifting pretty well, so…we used that). not sure if there is a comparable thing in C#?
No problem! Happy to share. I wish I was better at C#. The key to the method I was using is exploding the mesh, (each face of the mesh becomes an individual mesh). I have an example of exploding a mesh in C#, (but I’m not great with it). The attached file maybe starts to get you in the right direction? process would probably be something like, explode the mesh->deconstruct the resulting meshes->reconstruct with calculated slope values.
I’ll be watching this thread to see if you can get it! The only way I know, to color meshes “by face”, (if that is the goal), is to explode the mesh somehow. Which creates unique vertices for each face/new mesh. (granted, it does result in overlapping/duplicate vertices for neighboring meshes). Then you color the vertices for each mesh the same color. Good luck! I would be interested to learn if there is another/better way!
PS- the ExplodeAtUnweldedEdges method does seem to work, but you need to unweld first.
i tried to change the definiton to measure the slope of an Curve, for that reason i shattered the Curve and extracted the Tangent Vector at the midpoint, to measure the angle between the XY Plane.
I am not sure if this is the right way?
When i have a planar Curve the output angles are 90 which seems reasonable, but i some kind of got stuck at this point.