Author Topic: Environment Variables  (Read 442 times)

Hello,

Trying to figure out how to bring in modules via environment variables I've tried setting it up on the launch using
Quote
SUBSTANCE_PAINTER_PLUGINS_PATH
but it doesn't seem to work. Is it that your entire module has to live with in the modules folder provided by substance painter in the documents folder? or is there a way to load in modules from another location?

I'm not sure why Dev's won't answer any questions regarding this.
lol, I've posted the same question with replication steps and got nothing.
it's been a few months sensei asked. :(
Senior Technical Artist
Bethesda Game Studios

The trick is to have correct subfolders in the location pointed by SUBSTANCE_PAINTER_PLUGINS_PATH
if you add "startup" folder there and put your plugins into it then substance painter will load them on startup for you.
as far as I know, this is not documented anywhere and took a bit of try and error to figure it out.

Adding to this if you open WINDOWS command line and go:
NOTE: I'm using SP 6.2.2

LINE 1: set SUBSTANCE_PAINTER_PLUGINS_PATH="your\folder\with\plugins"
LINE 2: "path/yo/your/exe/Substance Painter.exe" "path/to/your/spp/project.spp"

Then within SP python console you go:
>>> import substance_painter_plugins
>>> substance_painter_plugins.path

What I get is:
['one/default/folder', 'another/default/folder', 'C:\\Users\\{your user here}\"your\folder\with\plugins']

The last item in the list "'C:\\Users\\{your user here}\"your\folder\with\plugins'" is a string mixed from the path I set before in the SUBSTANCE_PAINTER_PLUGINS_PATH env. varaible and the windows user folder, which is very extrange because if you print os.environ["SUBSTANCE_PAINTER_PLUGINS_PATH"], it works fine.

The startup trick posted by @Fin Design is not working for me.

To me it looks like SP is not appending the paths correctly internally, which seems like an string manipulation error, at least on windows.

SP Developers, could you please have a look at this? Are we doing something wrong?

Kind regards,

Hi,

Some hints:
  • You should only add absolute paths in the SUBSTANCE_PAINTER_PLUGINS_PATH environment variable, like in the PYTHONPATH environment variable.
  • As explained briefly in the documentation for the substance_painter_plugins python module, the directories you add to SUBSTANCE_PAINTER_PLUGINS_PATH are expected to have 3 sub-folders:
    • plugins : Modules that are loaded as optional components.
    • startup : Modules that are always loaded at application startup.
    • modules : Utility modules, shared across plugins.
  • Finally you can take a look, in the substance painter installation folder, at the "resources/python/modules/substance_painter_plugins.py" file where this variable is used.

Let me know if it helps,
Last Edit: October 28, 2020, 04:30:58 pm
Lead Software Engineer
Substance Painter Team