Addon - function when addon is started?


I tried different handlers, timers, schedules, nothing works

python does not seam to have serious threaded timer functions and bpy handlers never get called

how can I parse all blender scene objects when my addon loads ?


Add-ons aren’t “started” at any point - they load as part of Blender’s load on new or existing files. Your best option will be the load_post handler

tried that, it never triggers (as I load a blend file)

from import persistent
def load_handler(dummy):
    <do whatever>

It only triggers if you append your function to the existing load_post handers :slight_smile:

yes, never worked for me, my function is never called, hence this post
(yes I did not miss the persistent annotation either)

I put that code in, should I put it somewhere else ?

Interesting :thinking: I don’t mean to invalidate your experience at all, but I copied and pasted that code from an add-on I’ve written and it works perfectly there. It must be because you’re using a multi file addon. I would say you should put it in whichever file has your addon info- the dict with the name, version, etc. failing that, I’d put in it whichever file is calling your operators

yes !!
thanks it works, I have added your code to the panel class file

IMO the best place to register handlers is the addons register function:

# In file
def my_load_post(arg1, arg2):
    print(".blend file finished loading")

def register():

def unregister():
1 Like

yep, tried that, but I register in and it’s never called apparently

as far as I understand, registered classes get loaded, but not which is just there for installation

You are correct, can be entirely empty and still work fine

Sounds like something might be wrong with how your files are structured then.

Your should be in the main folder of your addon, and contain things like the bl_info dict and the register/unregister functions. Blender will then call the register functions automatically when the addon is enabled/disabled or on startup/quit of Blender.

See for example:

1 Like