0
$\begingroup$

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?

$\endgroup$

1 Answer 1

1
$\begingroup$

A persistent onload handler

Application handlers.

Code taken directly from Persistent Handler Example

import bpy
from bpy.app.handlers import persistent


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


bpy.app.handlers.load_post.append(load_handler)

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

bpy.data.is_dirty

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

$\endgroup$
1
  • $\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
    Commented 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 .