Mesh reverts back to the state before the script was run

by Armored Wolf   Last Updated May 15, 2019 21:15 PM

I created a script (operator) that converts a selection of quads into a diamond pattern.

It works fine but when I try to Inset the newly created selection and change any of the options (like switching to individual face insets) the mesh seems to revert back to the original topology before my script was even run (see image below).

Image Example: enter image description here

I noticed that if I change the selection somehow after running my operator I stop having the Inset issue, so I'm assuming my script is missing some command to fully apply the changes it makes to the mesh or something.

Here's my operator:

import bpy
import bmesh

def main(context):

    context = bpy.context
    ob = context.edit_object
    me =
    bm = bmesh.from_edit_mesh(me)

    bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')

    originalEdges = set(e for e in bm.edges if


    allEdges = set(e for e in bm.edges if


    borderEdges = set(e for e in bm.edges if

    diamondEdges = allEdges - originalEdges - borderEdges

    originalWithoutBorder = originalEdges - borderEdges


    for e in originalWithoutBorder: = True


    for e in diamondEdges: = True

    bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
    bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')   

    newFaces = set(f for f in bm.faces if
    bpy.ops.mesh.select_face_by_sides(number=3, type='EQUAL', extend=False)
    triangleFaces = set(f for f in bm.faces if

    newFaces = newFaces - triangleFaces
    for f in newFaces: = True


class VitalyPoke(bpy.types.Operator):


    [Vitaly Poke]

    Uses the Poke operator and some caveman code to convert a selection of quads into diamond-looking faces


    bl_idname = "arc.vitaly_poke"
    bl_label = "Vitaly Poke (ARC)"

    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        return {'FINISHED'}

def register():

def unregister():

if __name__ == "__main__":

Related Questions

Updated August 10, 2015 17:06 PM

Updated August 11, 2015 17:06 PM

Updated June 09, 2016 08:06 AM

Updated August 01, 2015 13:06 PM

Updated May 31, 2016 08:06 AM