12
$\begingroup$

In Blender, is there a command to query what's the current path to the Add-on folder - regardless of what system I'm using?

$\endgroup$

3 Answers 3

12
$\begingroup$

Ah, got it.

Paste this to the Python Console to get your add-ons path:

bpy.utils.user_resource('SCRIPTS', "addons")

Also see the wiki.

$\endgroup$
2
  • 2
    $\begingroup$ Note, there can be multiple addon's directories (3 infact) UsersHome/UserPrefs/BlenderDefault. The example you give will only give the user's home directory addon path, which might not even exist. $\endgroup$
    – ideasman42
    Dec 12, 2014 at 14:22
  • $\begingroup$ Oh, good to know. I guess they're listed here: blender.org/manual/installing_blender/directorylayout.html $\endgroup$ Dec 12, 2014 at 14:24
11
$\begingroup$

If you want to know the directory of the currently-executing addon, try this:

import os

script_file = os.path.realpath(__file__)
directory = os.path.dirname(script_file)

This is especially useful if your addon is a Python package, because it tells you which is the relevant subdirectory.

$\endgroup$
2
$\begingroup$

Blender addon utils module can fetch the path of any given addon name if installed.

#iterate through all the addon name installed
#if The Addon Name exists then: 
#.__file__ will give away the file path where it is installed
#We are printing the file path in console
#If the given name does not exist it will pass

import bpy
import addon_utils

for mod in addon_utils.modules():
    if mod.bl_info['name'] == "The Addon Name":
        filepath = mod.__file__
        print (filepath)
    else:
        pass
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .