I would like to check mesh for any modifications in Scripting API in mesh topology, such as adding or deleting vertices/faces. Is there a callback or function that works for this purpose?
1 Answer
$\begingroup$
$\endgroup$
1
Yes, you can use Depsgraph and handlers (depsgraph_update_post/pre) for that. For example,
import bpy
def mesh_change_listener(scene, depsgraph):
# check if we need to iterate through updates at all
if not depsgraph.id_type_updated('MESH'):
return
for update in depsgraph.updates:
if isinstance(update.id, bpy.types.Mesh):
print('Mesh \"{}\" updated.'.format(update.id.name))
do_your_stuff(update.id)
if __name__ == '__main__':
bpy.app.handlers.depsgraph_update_post.append(mesh_change_listener)
-
$\begingroup$ But if we subscribe to bpy.types.Object with msgbus, how do we retrieve the knowledge which object exactly got updated? $\endgroup$– D. SkarnCommented May 9, 2020 at 10:06