Hello there, I’m currently trying to find solution to my script that is trying to save version of my blender main file with as little residual data as possible to a separate folder, but then return all those data back. I am using the bpy.ops.ed.undo_push first, then continue with a for loop that goes through all the Actions, Materials, Images and such to purge them all, save the file and then do undo with the bpy.ops.ed.undo() line of code.
The issue currently is that I want to return to the actual state of the file at the point of doing the save point via the undo push but I assume the bpy.ops.ed.undo() does not necessarily return to that point but only to the one step before? Or at least some of the actions executed by the script did not return to the desired point even though all the purged data got returned to the file. For example if I have mesh with material linked the material does not get linked anymore and I need to manually press undo to link it again.
So my question would be if there is a way to somehow track the steps so I can accurately use the undo operator as many time as it would be necessary to return to that desired point. Or is there is a better solution how to return to certain state without doing multiple undo actions? Thanks!