External ("res") file "installation" for an Addon...

(I’m sorry, in advance, for my bad English! XD), I have an addon that uses an external (“res”) image file, provided with the .py in a .zip archive (so the user has to install the add-on by loading the .zip archive in User Preferences - Install Add-On); the problem is that I want to “install” (or, better, copy) the image file when installing the add-on, which loads that file with a local path.

If the script is… a script, not an Add-on, I can specify the path and load the file, no problem here; the problem is “installing” / loading (providing, perhaps) an external file with an Add-On, which has to be installed.

What do I have to do to use external, “res” files in an Add-On? Should I specify the path of external files to be carried on with the .py somewhere in the script? Or in a init/“manifest” file?

I’m sorry (again) for my bad English… thank you in advance :wink:

you should make your script an addon module, basically a folder with a init.py script, which may include the entire code, or you can separate code logically into multiple files. Put the image inside the folder and zip the entire dir. On installation, blender will unpack and copy the content to %appdata%\Blender Foundation\Blender\2.XX\scripts\addons\ (on windows; xx = subversion, i.e. 66)

Note that you can’t load an image into blender from register() function, you need to do that in an operator which the user has to run (e.g. an “Initialize” button in a panel).

1 Like

thank you very much! :wink: