I need to call the unregister function before disabling the addon. I can get this information about the addon:
addon_collection = {}
for addon in addon_utils.modules():
addon_name = addon_utils.module_bl_info(addon)
addon_file_name = addon.__name__
# my_name.update({addon_name['name'] : addon_file_name})
addon_items = {addon_name['name'] : addon_file_name}
addon_collection.update(addon_items)
print(addon_collection)
I get such a dict with keys.
{'Magic UV': 'magic_uv',
'TexTools': 'TexTools_1_5',
'3D Navigation': 'space_view3d_3d_navigation',
'Stored Views': 'space_view3d_stored_views',
'Cycles Render Engine': 'cycles'}
Also, I can get the path to the file:
for addon in addon_utils.modules(refresh=False):
print(addon.__file__)
D:\blender\0\3.1\scripts\addons\node_presets.py
D:\blender\0\3.1\scripts\addons\node_wrangler.py
D:\blender\0\3.1\scripts\addons\space_view3d_align_tools.py
D:\blender\0\3.1\scripts\addons\object_boolean_tools.py
D:\blender\0\3.1\scripts\addons\object_carver\__init__.py
D:\blender\0\3.1\scripts\addons\object_fracture_cell\__init__.py
D:\blender\0\3.1\scripts\addons\drop_it\__init__.py
From these lists it turns out that I can refer to the addon
- By file name
- The name of the addon
- The path to the addon file
How to call unregister function? Without knowing the internal classes or other functions that have different names, but are somehow called when the unregister function is triggered. Thank you in advance )