Compute vertex colors in grasshopper

Things work fine when I import the mesh in Rhino 8. I can compute vertex colors and reference everything in Grasshopper.

The goal in Rhino 9 however is to either insert the mesh as linked block or import the mesh with the import content component in Grasshopper.

Is it possible to compute the vertex colors in Grasshopper Rhino 9?

1 Like

gockel_8.3dm (13.3 MB)
gockel_8.gh (16.6 KB)

gockel_9.3dm (13.3 MB)
gockel_9.gh (22.8 KB)

Hello
here is one way but it uses Nautilus (so also work on Rh7) plugin to get UV mesh. But if you program a bit it is not difficult to get the UV coordinates. One drawback is that you need to put the texture file name in Image Sampler. I didn’t search if there is a material deconstruct in RH8 or RH9
Other problem is that it is the texture vertex color and not the render vertex color. I imagine it is not the last you want as it depend on the render, lights, position …



gockel_9.gh (16.6 MB)

1 Like

Thanks for the hints.

Copilot wrote the python script. I modified it a bit and it works:

import rhinoscriptsyntax as rs
import Rhino

def extract_uv_points(mesh):
    if not rs.IsMesh(mesh):
        return []

    uv_points = []
    for i in range(mesh.Vertices.Count):
        uv = mesh.TextureCoordinates[i]
        uv_points.append(Rhino.Geometry.Point3d(uv.X, uv.Y, 0))
    
    return uv_points

uv_points = extract_uv_points(mesh)

Wait :slight_smile: Rhino 9 has a component called ‘Texture Evaluator’

texture_evaluate_uv.gh (13.9 KB)

2 Likes

Thanks guys! This was exactly what I was looking for!