There may be other solutions, this could be one of them.
When Blender is opened or addon is activated, the current time is compared with the installation time of the addon. For this we need modules addon_utils
and datetime
. First is not in API. Look at BlenderDefault/scripts/modules/addon_utils.py
Less than 1 minute is considered new in this example. The disadvantage is that you need to activate the addon for the first call within 1 minute.
bl_info = {
"name": "first call test",
"blender": (2, 83, 0),
"category" : "All"
}
import bpy
def first_time():
print("\n...check addon")
import addon_utils # not in API
from datetime import datetime
for mod in addon_utils.modules():
if mod.bl_info.get('name') == 'first call test': # get module
time_mod = mod.__time__ # get mod_install_time as timestamp
time_now = datetime.timestamp(datetime.now()) # get actual_time as timestamp
print("Modul:", time_mod, datetime.fromtimestamp(time_mod))
print("Now: ", time_now, datetime.fromtimestamp(time_now))
if (time_now - time_mod) / 60 < 1: # difference less than 1 min
print("i am new")
else:
print("i am old")
### REGISTRY
classes = ()
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
first_time() # testcall
def unregister():
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
if __name__ == "__main__":
register()