My addon relies on checking bpy.data.is_dirty. This seems to work fine in interactive mode, however when I tried adding automated tests for my addon I have faced issue with bpy.data.is_dirty not updating correctly when things are getting changed from my tests (Python script).

Example script to reproduce (on Blender 2.79):

>>> bpy.data.scenes[0].frame_start = bpy.data.scenes[0].frame_start + 1
>>> bpy.data.is_dirty

I can see starting frame change on the timeline, however there is no asterisk "*" visible in title (which generally indicates unsaved changes). If I change starting frame by clicking on small arrow by number it marks the file correctly as changed (both the asterisk appears and bpy.data.is_dirty returns `True).

I have also managed to get a state in tests that have bpy.data.is_dirty returns True even on the next line just after call to bpy.ops.wm.save_mainfile().

Is there some function I need to call to get Blender's internal state to update bpy.data.is_dirty?

Alternatively, as I need it only for tests, is there some way to make sure that bpy.data.is_dirty is in a desired state? (i.e. I need to be able to set it both to True and False depending on scenario)

I read https://docs.blender.org/api/2.79/info_gotcha.html#no-updates-after-setting-values and tried using bpy.context.scene.update(), but it doesn't seem to impact bpy.data.is_dirty.

  • $\begingroup$ There are many problems with "bpy.data" updates, I suggest you report this $\endgroup$
    – Noob Cat
    Oct 21, 2019 at 22:36


You must log in to answer this question.

Browse other questions tagged .