I'm looking for a sort of event listener that triggers after a transform has finished. So far i found this:

def scene_update(context):
    if bpy.data.objects.is_updated:
        print("One or more objects were updated!")
        for ob in bpy.data.objects:
            if ob.is_updated:
                print("=>", ob.name)

I need to add something so that the print only happens after the translation of a vertex is completed (not while i'm still dragging the vertices around). Any idea what ?


1 Answer 1


This is a mix of the answers here Find out if Mesh Operator (bpy.ops.mesh...) was cancelled or not via python and How to get the active vertex within a Handler?

Looks for bpy.ops.transform.translate as the active operator and if used prints out the selected verts and amount transformed.

import bpy, bmesh
from bpy.app.handlers import persistent
from mathutils import Vector

def check_operators(bm):
    op = bpy.context.active_operator
    if op:
        if op.bl_idname == 'TRANSFORM_OT_translate':  #bpy.ops.transform.translate.idname()
            #print("bpy.ops.transform.translate(%s)" % " ,".join(["%s=%s" % (k, str(v)) for k, v in op.properties.items()]))
            v = Vector(op.properties["value"])
            if v.length:
                print("value", str(v))
                print("verts", [v for v in bm.verts if v.select])
                print("operator canceled")

dic = {}
def edit_object_change_handler(scene):

    obj = scene.objects.active
    if obj is None:
        return None

    if obj.mode == 'EDIT' and obj.type == 'MESH':
        bm = dic.setdefault(obj.name, bmesh.from_edit_mesh(obj.data))
        return None

    return None

def register():
    bpy.app.handlers.scene_update_post.clear() # for testing


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .