# How to reset add-on preferences?

I'm surprised that I can not find an answer to this one. Is there any way to restore a specific add-on's preference states to the defaults?

I would prefer not to uninstall the add-on if possible.

You can create an Operator and make it part of the Preferences layout for your custom add-on:

class MyAddonPreferences(bpy.types.AddonPreferences):

bl_idname = __name__

display_flag: bpy.props.BoolProperty(
name="Display Flag",
default = True)

def draw(self, context):
...


Best practice is using property_unset(property):

class MYADDON_OT_resetPreferences(bpy.types.Operator):
bl_label = "Reset Properties and Settings"
bl_options = {"INTERNAL"}

def execute(self, context):
prefs.property_unset("display_flag")
...
return {'FINISHED'}


In order to reset the properties of a certain add-on it's basically the same, you just need to find a way getting the name of each property.

Example on how to reset the settings of Loop Tools by reading its annotations using the Console:

>>> prefs = C.preferences.addons['mesh_looptools'].preferences
>>> props = prefs.__annotations__.keys()
>>> for p in props:
...     prefs.property_unset(p)

• So essentially call property_unset() for each preference variable? This is really useful, thank you. What about from a user's perspective - a user wanting to clear an add-on's preferences without scripting? I haven't experimented much with this, but how would they usually go about doing this? Is there a folder or file where these settings are saved per-project? Thanks again! – Robert Sep 16 '19 at 17:34
• There is no generic option for the user atm, you have to provide that @Robert – brockmann Sep 16 '19 at 18:17