I want to know which add-ons in Blender 2.79 are enabled by me.
-
$\begingroup$ Do you want to get the enabled add-ons, excluding those that are enabled by default, or all add-ons that are currently enabled? $\endgroup$– Robert GützkowCommented Feb 9, 2020 at 17:14
-
$\begingroup$ @RobertGützkow Yes, excluding those add-ons enabled default . $\endgroup$– Basara KubikiriCommented Feb 10, 2020 at 1:07
2 Answers
Blender's Python API allows to get the currently enabled add-ons, without any differentiation of what/who enabled them. Therefore it's not possible to distinguish between add-ons that have been enabled by default, by the user or by another add-on/script. You may however compare the currently active add-ons to the ones that are known to be enabled by default and only use those that are not it the default list.
Blender 2.79
The enabled add-ons can be access through the user preferences bpy.context.user_preferences.addons
.
import bpy
for addon in bpy.context.user_preferences.addons:
print(addon.module)
The add-ons that are enabled by default are:
io_scene_3ds
io_scene_fbx
io_anim_bvh
io_mesh_ply
io_scene_obj
io_scene_x3d
io_mesh_stl
io_mesh_uv_layout
io_curve_svg
cycles
Therefore a solution that excludes them could look like this:
import bpy
default_addons = {"io_scene_3ds",
"io_scene_fbx",
"io_anim_bvh",
"io_mesh_ply",
"io_scene_obj",
"io_scene_x3d",
"io_mesh_stl",
"io_mesh_uv_layout",
"io_curve_svg",
"cycles"}
for addon in bpy.context.user_preferences.addons:
if addon.module not in default_addons:
print(addon.module)
Blender 2.8x
The enabled add-ons can be access through the preferences bpy.context.preferences.addons
.
import bpy
for addon in bpy.context.preferences.addons:
print(addon.module)
The add-ons that are enabled by default are:
io_anim_bvh
io_curve_svg
io_mesh_ply
io_mesh_stl
io_mesh_uv_layout
io_scene_fbx
io_scene_gltf2
io_scene_obj
io_scene_x3d
cycles
Therefore a solution that excludes them could look like this:
import bpy
default_addons = {"io_anim_bvh",
"io_curve_svg",
"io_mesh_ply",
"io_mesh_stl",
"io_mesh_uv_layout",
"io_scene_fbx",
"io_scene_gltf2",
"io_scene_obj",
"io_scene_x3d",
"cycles"}
for addon in bpy.context.preferences.addons:
if addon.module not in default_addons:
print(addon.module)
-
$\begingroup$ But that won't get add-ons specifically enabled by the user, will it? It will also get add-ons that come pre-enabled? (I haven't tested this yet, just wondering.) $\endgroup$ Commented Feb 9, 2020 at 14:05
-
$\begingroup$ @RayMairlot Since users also have the ability to disable and re-enable the default add-ons, it's not possible to distinguish the default activated and user activated add-ons. You can only retrieve a list of currently active add-ons, how that state came to be is unknown. $\endgroup$ Commented Feb 9, 2020 at 14:09
-
$\begingroup$ So shouldn't that be in the answer as I think that is what the user is asking for? $\endgroup$ Commented Feb 9, 2020 at 16:25
-
$\begingroup$ @RayMairlot Updated the answer. $\endgroup$ Commented Feb 9, 2020 at 17:01
-
1$\begingroup$ @BasaraKubikiri Yes that would be a way to solve this $\endgroup$ Commented Feb 10, 2020 at 7:34
Enabled addons list for blender 2.79 in human-readable format:
enablist = [addon.module for addon in bpy.context.user_preferences.addons]
for addon in addon_utils.modules():
if addon.__name__ in enablist:
print ('{name} {ver} {mod}'.format(
mod = addon.__name__,
name = addon.bl_info['name'],
ver = ''.join([str(v) + '.' for v in addon.bl_info['version']]).rstrip('.')))
Update for 3.0+:
import addon_utils
enablist = [addon.module for addon in bpy.context.preferences.addons]
for addon in addon_utils.modules():
if addon.__name__ in enablist:
print ('{name} {ver} {mod}'.format(
mod = addon.__name__,
name = addon.bl_info['name'],
ver = ''.join([str(v) + '.' for v in addon.bl_info['version']]).rstrip('.'))) if 'version' in addon.bl_info else None