pythonblender

How to get Blender script path that is running


How do I get the full path of the current file's directory?

Yes, I already tried these methods. They all give me the folder that contains Blender.exe which is D:\program\Blender 2.90

And what I supposed to get is C:\Users\username\AppData\Roaming\Blender Foundation\Blender\2.90\scripts\addons\someAddonFolder right?

Is something changed in version 2.9? Without the Blender environment, I mean run under normal Python. Methods from that topic all work well. Did I miss something?

The old way I made the script work is by putting .blend .json .py all together in the same folder. and refer to the relative path using //


Solution

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

    use this code can get you the path your custom addon you install at. for me, it's 'C:\Users\Naoki\AppData\Roaming\Blender Foundation\Blender\2.90\scripts\addons'

    found the answer over here: https://blender.stackexchange.com/questions/20850/how-to-automatically-get-a-add-on-folders-path-regardless-of-os