i am building a Rhino.Geometry.Mesh from another mesh by copying it and then chaning the vertex locations. After this is done, i update the vertex normals and facenormals. While doing this, i ran in a situation where some meshes cannot be added to the document in V5 and V6 using:
which results in an empty guid. If i query new_mesh.IsValid before i try to add the mesh to the document, i get False. Is there a way to find out what is not valid with the new mesh ? (It is manifold, compacted etc)
If you have a sample for a simple mesh where this doesn’t work, I would sure like to see it. You shouldn’t have to worry about keeping these lists synchronized
Hi @stevebaer, i stripped down as much as possible. Below example makes the first error “ON_Mesh.m_dV[] and m_V[] are not synchronized” appear when i try to add the mesh to the doc.
new_mesh.Vertices.Clear()
# Since you've cleared the vertices, make sure
# Rhino knows you want new vertices to be
# double-precsion vertices...
new_mesh.Vertices.UseDoublePrecisionVertices = True
new_mesh.Vertices.AddVertices(new_vertices)
Message: ‘MeshVertexList’ object has no attribute ‘UseDoublePrecisionVertices’
unfortunately this is V5. In V6 it seems to fix the problem. Is there anything i can do to make it work in V5 as well ? I’ve tried all kinds of things to make the vertices Point3d or Point3f but that failed.
Anyway, instead of clearing the vertices, how about just replacing them?
for i in xrange(new_mesh.Vertices.Count):
vtx = mesh_obj.Geometry.Vertices[i]
dir = mesh_obj.Geometry.Normals[i]
new_mesh.Vertices.SetVertex(i, vtx + dir)
I would like to update the TopologyVertices instead of the Vertices, this improves speed like hell in my given case (no welded edges because I need individual UV coordinates…)
M.TopologyVertices[i] = some Point3f;
When I do this I get : ON_Mesh.m_dV[] and m_V[] are not synchronized
Workarround for now is to create a new mesh and append the old mesh to the new Mesh, that helps…
Topological mesh vertices are no different from standard mesh vertices. Thus, you can just use MeshVertexList.SetVertex. Doing this will ensure any double-precision vertices are in-sync with single precision vertices.
Setting all Vertices that correspond to a Topological Vertex individually takes realy realy long compared to setting the topological vertex … Difference is waiting for a minute . waiting for 5 seconds…
Hmm okay, but why do the two list end up not being synchronised when setting the TopologyVertice? couldn’t that be considered a bug?
I mean as fare as I understand every time SetVertex is called the Topology of the MEsh is recomputet which than takes ages compared to changing the location of the TopologyVertice…
But then why is setting each Vertex individually like you proposed so much slower than setting the Topology Vertex? Is there any way to see what happens in the corresponding method?