Fast way to update mesh Vertices


#1

hello,
i have trouble updating mesh vertices - SetVertex is slow, so i tried to use:

myvertexlist = mesh.Vertices.ToPoint3fArray()    
mesh.Vertices.Clear()
mesh.Vertices.Add(myvertexlist)

this works fine, but when i change any properties (x,y,z), they wont show on the mesh, and if i
say something like:

myvertexlist[0] = Rhino.Geometry.Point3f(100,100,100)

then the mesh wont show up at all…

So my question is - why does changing the list destroy the mesh, and is there a faster way to update a lot of vertices?

thanks!


#2

Hi Damjan,

you might need to recreate the mesh and delete the old mesh to see changes made on the mesh vertices. You also can replace the old mesh with the updated one to match the properties of the old mesh. One alternative is to use grips instead. But it is not much faster then above method.

c.


#3

yes - that worked fine:
i create a new empty mesh,
add the vertices (AddVertex)
and then add the faces as a list from the original mesh

newmesh = Rhino.Geometry.Mesh()
for i in xrange(0, myvertexlist.Count):
    newmesh.Vertices.Add(myvertexlist[i])
newmesh.Faces.AddFaces(mesh.Faces)

is fast enough for me


(Giulio Piacentino) #4

Hi Atair,
The method to add a list of vertices to the mesh vertices list is called AddVertices.
I doubt that mesh.Vertices.Add() above will do what you are after.

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


#5

great :wink:

c.


#6

piac - true, i overlooked that one, now it is even faster