I need to create a few meshes where vertex index order is important. I am trying to write a script as such:
import bpy import bmesh mesh = bpy.context.object.data print(mesh) bm = bmesh.new() bm.from_mesh(mesh) bm.verts.ensure_lookup_table() def switchIndices(i1, i2): v1 = bm.verts[i1] v2 = bm.verts[i2] bm.verts[i1] = v2 bm.verts[i2] = v1 switchIndices(32, 4)
But when I try to write to bm.verts it says it cannot. I can assign/swap the values of v1 and v2 but then I still need to edit edges and when I try to change the two vertices of an edge I get the same write problems. I thought the whole point of the bmesh was to be able to edit it. What am I doing wrong?