My logic is as following:
1. First, use the primvertices to get linear vertex indices for each primitive.
2. Then, convert these vertex indices into point index by using vertexpoint.
3. Finally, access the "Cd" with the point index and calculate the average color for each primitive.
Here is my Vex code that run over primitive:
int verticeIndex[] = primvertices(0, @ptnum); vector colorArray[] = array(); foreach(int vertexIndex; verticeIndex) { int posIndex = vertexpoint(1, vertexIndex); vector pointColor = point(1, "Cd", posIndex); append(colorArray, pointColor); } vector newcolor = sum(colorArray) / len(colorArray); setprimattrib(0, "Cd", @ptnum, newcolor);
But my code does't work, can some one help me to check my code?

