SOLVED Load file from plugin directory

Ok, I'm developing a tag plugin and I have specific splineData stored in a hyperfile that the tag needs to load when starting.
This works fine on my own computer:

path = os.path.join("/Applications","thedrive","Dropbox","INTERNAL","MyTag","SPLINEDATA")

but if I want to give the plugin to a co-worker or sell it how do I create the path? Am I able to put the splineData file in my plugin's /res folder and load it from there? What would that code look like?
I can't seem to find a standard python example that works for this.
Thank you for any insight.


I don't know where you are planning to store your data, but remember that the constant __file__ in Python holds the file path of the currently interpreted script. So os.path.join(os.path.split(__file__)[0], "splinedata") for example would point to a folder called "splinedata" in your plugin directory, no matter where the plugin folder lies (assuming the python file lies on the top level).

You can also get the 'important' c4d paths via


@zipit said in Load file from plugin directory:

os.path.join(os.path.split(file)[0], "splinedata")

Amazing, that's works perfectly. Thank you!


@zipit thanks for your answer.

for your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here.

I've added the tags and marked this thread as a question so when you considered it as solved, please change the state 🙂

In the python help, you have a link to github where you can find examples.

you will see sometimes in those example this code :

    path, fn = os.path.split(__file__)
    bmp = bitmaps.BaseBitmap()
    bmp.InitWith(os.path.join(path, "res", "gravitation.tif"))

Just to add a few words about That's the classic API.

In c++ with the maxon API you have GetUrl

In Python, in r20 symbol are not set and if you want to retrieve the resource directory it will return the Cinema4D's one and not your plugin's one.