Returns or modifies the vertex colors of a mesh object
rhinoscriptsyntax.MeshVertexColors (mesh_id, colors=0)
rhinoscript.mesh.MeshVertexColors (mesh_id, colors=0)
mesh_id |
Required. String or Guid. The object's identifier. |
colors |
Optional. List. A list of color values. Note, for every vertex, there must be a corresponding vertex color. If the value None is passed, then any existing vertex colors will be removed from the mesh |
List |
If colors is not specified, the current vertex colors if successful. |
List |
If colors is specified, the previous vertex colors if successful. |
None |
If mesh_id does not have vertex colors, if not successful, or on error. |
import rhinoscriptsyntax as rs
import random
def randomcolor():
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
return r,g,b
obj = rs.GetObject("Select mesh", rs.filter.mesh)
if obj:
colors = []
for i in range(rs.MeshVertexCount(obj)): colors.append( randomcolor() )
rs.MeshVertexColors( obj, colors )