Can I set the individual UV coordinates of a mesh from inside a python script?

Looking for a more verbose UV solution to handling the individual mesh vertices.

for all intents and purposes, some pseudocode might look like the below. I just can’t quite understand how to manipulate the UV attribute… If that is indeed how you would go about it:

mesh = importMesh
rows = 10
columns = 10

meshUVcoOrd = []

for i in range(rows-1):
for j in range(columns-1):




below creates a new array of uv-coordinates based on the mesh vertex xy position and assigns them:

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
import System

def DoSomething():
    mesh_id = rs.GetObject("Mesh", 32, True, False)
    if not mesh_id: return
    m_obj = rs.coercerhinoobject(mesh_id, True, True)
    count = m_obj.Geometry.Vertices.Count
    uv_tx = System.Array.CreateInstance(Rhino.Geometry.Point2f, count)
    for i, vertex in enumerate(m_obj.Geometry.Vertices):
        uv_tx[i] = Rhino.Geometry.Point2f(vertex.X, vertex.Y)




Excellent! Thanks @clement!!