I have a driver script being called on an empty's position properties. When the user moves the empty, I'm regenerating a mesh based on the position of the empty. The driver script runs, but the mesh doesn't visibly change (until I go into edit mode afterward). Here's basically what the script is doing:

obj = bpy.data.objects.get(name)
mesh = obj.data
mesh.from_pydata(verts, [], faces)

I tried calling obj.update_tag() but that did nothing (perhaps it's too late in dependency graph update?). I also tried calling context.view_layer.update() but that gave the error "Dependency graph update requested during evaluation".

I'm using a driver script because it makes it easy to bind to specific property changes of the empty (position, scale, etc.).

Is there a better way to be doing this or a way to force the mesh to update?


1 Answer 1


Seems like driver related dependency graph issues are common and often go unanswered on StackExchange.

I figured out a workaround:

  1. Modified the driver script to only set a boolean variable to note that a change happened. The driver script also saves what data was changed by the driver.
  2. Added a depsgraph_update_post handler script that does the actual mesh changes (see sample code above).

This approach fixed the problem as it appears that mesh changes made in the update_post of the dependency graph gets updated properly in the 3D view.

Takeaway: Don't modify meshes directly in a driver script because the dependency graph doesn't update it properly until after edit mode.


You must log in to answer this question.

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