Hi,
I’m trying to get different colors at different heights of a mesh.
What I do is:
Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As RunMode) As Result
Dim MyMesh As Rhino.DocObjects.ObjRef = Nothing
Dim Rc As Rhino.Commands.Result = Rhino.Input.RhinoGet.GetOneObject("Click on Mesh", False, DocObjects.ObjectType.Mesh, MyMesh)
If Rc <> Rhino.Commands.Result.Success Then
Return Nothing
End If
Dim Mesh As New Geometry.Mesh
Mesh = MyMesh.Mesh.Duplicate
Dim Count As Integer = Mesh.Faces.Count
For i = 0 To Count - 1
Dim Pt3D As Geometry.Point3d = Mesh.Faces.GetFaceCenter(i)
If Pt3D.Z < 15 Then
Mesh.VertexColors.SetColor(i, Drawing.Color.Red)
ElseIf Pt3D.Z < 25 Then
Mesh.VertexColors.SetColor(i, Drawing.Color.Orange)
Else
Mesh.VertexColors.SetColor(i, Drawing.Color.Green)
End If
Next
doc.Objects.Replace(MyMesh, Mesh)
doc.Views.Redraw()
Return Result.Success
End Function
And I get:
Colors are being placed randomly. It’s not using the Pt3d.Z right. After red orange should come. why is there green? What am I doing wrong?
I’m getting the center of a face. Checks its height and give it a color and replace the mesh.
I guess the i isnt taking the same VertexXolors.Setcolor as Faces.GetFaceCenter