`ImpMesh = Original Mesh ID
Dim Mesh As Geometry.Mesh = New DocObjects.ObjRef(ImpMesh).Mesh.Duplicate
Dim Red As Drawing.Color = Drawing.Color.FromArgb(255, 0, 0)
If Mesh.VertexColors.Tag.Id <> MyID Then
Dim colors As System.Drawing.Color() = New System.Drawing.Color(Mesh.Vertices.Count - 1) {}
For i As Integer = 0 To Mesh.Vertices.Count - 1
colors(i) = Red
Next
Mesh.VertexColors.SetColors(colors)
End If
doc.Objects.Replace(ImpMesh, Mesh)
Looks a bit messy when it’s pasted in here
But probably you can do what you are doing now but you didnt Duplicate the original mesh and replaced it in the file
Jordy: Thanks for the example. So it’s not possible to update an existing mesh’s colors and tell it to redraw itself? I have to duplicate the mesh, change its colors, and then replace the original? Can you explain why that’s necessary, so I have the right model in my head of how Rhino works internally?
David: I want to modify the colors of a mesh that’s already in the document.
Piac: The source language is the Wolfram Language. I edited to make it look like C#, but missed the square brackets.
All geometry ‘inside’ the Rhino document is const. Nobody except us is allowed to change it. To open it up would basically allow any plugin developer to make changes that are both unexpected, untraceable and unstable. In order for Rhino to be reasonably stable while running a large number of plugins, and in order for undo to work well without placing a huge amount of responsibility on plugin developers, and in order to validate simplifying assumptions so the display can be optimized, all access to geometry inside the document is bottlenecked.
So yes, if you want to modify an object inside the document; get a copy of it, modify that copy, then replace the original with the modified object. The original object will be placed into the undo-buffer and a copy of your modified object will be inserted into the document.