I'm using a Python class static members properties in order to store the state of the addon I'm developing. It works fine and my Python class is brand new every time I start Blender. Problem is, if I do file->new or revert, that class is not created anew and still stores values that are relevant to the old file. Is there any way to achieve that?


1 Answer 1


A persistent onload handler

Application handlers.

Code taken directly from Persistent Handler Example

import bpy
from bpy.app.handlers import persistent

def load_handler(dummy):
    print("Load Handler:", bpy.data.filepath)


Other things to consider re comment for revert and new is look at


for toggle from True to False. Wont matter if a clean file is reverted.

  • $\begingroup$ Thank you. So this will work in the load case. Not in file->new or revert cases. Nice to learn about handlers though. $\endgroup$
    – Kiskit
    Dec 9, 2019 at 9:29

You must log in to answer this question.

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