I have a scene which loads special image data from external files via an addon. After doing work in the file and saving it, these images should not and are not saved with the .blend file. When later opening the file again, I need the startup code to run again to load in the images again. Is there a way to hook into such a callback from register()
?
If I understand this correctly, couldn’t you add a call to this operator in your startup script? (In your default file, make a script, set to Register, and re-save as your default file)
I was hoping to be able to make this as effortless as possible for other people, i.e. you enable the addon normally, and that’s all you needed to do. And no, it wouldn’t quite work. There are thousands of images, only a selection of which should be loaded depending on which ones are used in the opened file. The best solution I have right now is to add a “YOU HAVE TO CLICK THIS BUTTON”-button using a panel in the scene tab.
You could try using a load_post handler to check every time a new file is loaded whether it is the one you’re looking for
Bullseye!
import bpy
from bpy.app.handlers import persistent
@persistent
def load_handler(nonDocumentedParam1, nonDocumentedParam2): # both params always None
print(len(bpy.data.scenes[0].objects))
bpy.app.handlers.load_post.append(load_handler)