← All ideas
  • Published 9 Jan 2023

Trigger a script after completing object transform

This stackexchange posting describes a handlers depsgraph_update script that I believe is exceptionally useful and otherwise quite challenging to devise.

It should be included as a Template Python Event template. Perhaps there are other candidates that should also be included, based on msgbus/subscribe_rna events.

def on_depsgraph_update(scene):
    depsgraph = bpy.context.evaluated_depsgraph_get()
    if on_depsgraph_update.operator is None:
        on_depsgraph_update.operator = bpy.context.active_operator
    for update in depsgraph.updates:
        if not update.is_updated_transform:
            continue
        if on_depsgraph_update.operator == bpy.context.active_operator:
            continue
        obj = bpy.context.active_object
        transformEvent(obj, scene)
        on_depsgraph_update.operator = None

on_depsgraph_update.operator = None

bpy.app.handlers.depsgraph_update_post.append(on_depsgraph_update)
100%

Development Status: Open

Upvote 12 Downvote 0
jamestomk
9 Jan 2023

0 Comments