Objects referring in a depsgrapth_update handler feature

When using the “depsgraph_update” handler, making actions with objects passed to the handler does not give the full result. For example, properties of an object referring to it through the “object.id”, could be not completely changed.

Let’s define the “depsgraph_update_post” handler, inside which we will change some object’s property, for example, the viewport color of the object.

After registering the handler let’s make any changes in the current mesh (to execute the handler).

In this example, to change the color of an object, we referred to it through the “object.id”:

As we can see, the color of the object in the viewport changes, but the color in the parameter on the object properties panel  – doesn’t. After unregistering our handler, when the mesh changes, its color is restored with the original color from the parameter.

To avoid this behavior, it is better to refer to the object by name through the “bpy.data.objects” list.

The same handler, with accessing an object through the “bpy.data.objects”, changes the color of the object completely both in the viewport and in the parameter:


*.blend file with the example code for my Patreon subscribers.

0 0 votes
Article Rating
Subscribe
Notify of
guest

4 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
vinod kumar
1 year ago

Hi

is there anyway to determine the source of the update? ie. Whether the event is happened on user dragged the object or through they changed location through property window?

Thanks

Octree
Octree
1 year ago

Hi, I have a question related to the depsgraph update for rendering an object from multiple cameras from different angles. Is there a way to stop the depsgraph update? as there is no actual change to the object itself, it is just the camera selection been changed.