Shifting face vertex order I need to shift the order of referenced vertices in a face. I've been trying to do it in python after being unable to find a &quot;normal&quot; way of doing it, but I've hit a bit of a dead end and I hope someone can help me.
To be more concise: Let's say, for example, a triangle face uses the vertices [1, 2, 3]. What I need is to shift those indices to [2, 3, 1]. Obviously it's the same triangle, but I need those indices to be in a certain order.
The furthest I can get is the following python script that shows the vertex indices of the selected triangle. I'd love to rearrange the &quot;verts&quot; member, but it's read-only.
import bpy
import bmesh

me = bpy.context.object.data
bm = bmesh.new()   
bm.from_mesh(me)  

for face in bm.faces:
    if (face.select):        
        print(&quot;face index %u&quot; % face.index)
            
        v0 = face.verts[0]        
        v1 = face.verts[1]
        v2 = face.verts[2]

        print(&quot;vertex 1: %u&quot; % v0.index)
        print(&quot;vertex 2: %u&quot; % v1.index)
        print(&quot;vertex 3: %u&quot; % v2.index)

I understand that bmesh is some kind of &quot;working copy&quot; of a mesh which then needs to be saved back. Do I need to make a new bmesh and then copy the old one while applying my changes somehow?
EDIT: Since I can't write comments myself, I'll address thibsert's comment here: As far as I can tell that just rearranges the &quot;global&quot; list of vertices of the mest, which I need to be untouched. It's the face's own list of corner vertices that I need to shift. I know this is a very fringe use case :)
I don't know how to do it with a bmesh, but it's easy with a regular mesh since mesh.loops[i].vertex_index is writable.
import bpy

ob = bpy.context.object
assert ob.type == 'MESH'

# If in edit mode, switch to object mode and switch back at the end
was_in_edit_mode = False
if ob.mode == 'EDIT':
    bpy.ops.object.mode_set(mode='OBJECT')
    was_in_edit_mode = True

me = ob.data

for poly in me.polygons:
    if not poly.select:
        continue

    # Get loops for this poly
    # Loop = corner of a poly
    loop_start = poly.loop_start
    loop_end = loop_start + poly.loop_total
    loops = [me.loops[loopi] for loopi in range(loop_start, loop_end)]

    # Get vertex indices for each loop
    vidxs = [loop.vertex_index for loop in loops]

    # Shift
    vidxs = vidxs[1:] + vidxs[0:1]

    # Write back
    for i, loop in enumerate(loops):
        loop.vertex_index = vidxs[i]

# Not sure if you need this
me.update()

if was_in_edit_mode:
    bpy.ops.object.mode_set(mode='EDIT')