@Terry_Chappell wrote:
The code below worked for jordy1989 to color a mesh: Dim colors As System.Drawing.Color() = New System.Drawing.Color(Mesh.Vertices.Count - 1) {} For i As Integer = 0 To Mesh.Vertices.Count - 1 Dim z As Double = Mesh.Vertices(i).Z If z < 10 Then colors(i) = Drawing.Color.Red Else colors(i) = Drawing.Color.Green End If Next Mesh.VertexColors.SetColors(colors)
How do I write this in a Python script using Rhino common calls? I cannot figure how to replace the line:
Dim colors As System.Drawing.Color() = New System.Drawing.Color(Mesh.Vertices.Count - 1) {}
I tried:
vcount = mesh.Vertices.Count colors = System.Drawing.Color[vcount]
but Python complains: Message: expected Array[Type], got int
I cannot use a list instead as the call to mesh.VertexColors.SetColors(colors) requires an array and not a simple Python list.
As a work around I am using:
for c in colors: mesh.VertexColors.Add(c)
but this is slow for my 20M face meshes. Please help!
Regards,
Terry.
Posts: 3
Participants: 2