1
$\begingroup$

I write an exporter, which exports PBR materials, mostly from the PrincipledBSDF shader. Would like to add a small directory of generic environment textures in my zip file, in a format that Blender does not use. Like a 2 umbrella studio environment texture, seen here as a reflection texture.

User could then also pick from a custom property list, in addition to a the .hdr in the world node. The file would get copied to the export directory.

Problem is how do I know where the directory from the addon is, in a completely OS independent way?

$\endgroup$
1
$\begingroup$

This gets the root directory of the add-on from any file (or at least those in the same directory). Can always do an os.path.join() if I need a sub-directory.

def getAddonPath():
    import os
    return os.path.dirname(os.path.realpath(__file__))
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.