Author Topic: [PYTHON][WINDOWS] Launch Substance Painter from Maya Python interpreter  (Read 241 times)

Hello all,

I have a python script in Maya that saves out an FBX file from selection and I want it to also Popen an instace of Substance Painter using that very FBX.
Essentially I do this:
Code: [Select]
subprocess.Popen([r'path\to\painter\Substance Painter.exe', '--mesh', r'path\to\fbx\geo.fbx', path\to\project], shell = True, stderr=subprocess.STDOUT)If I run it inside Maya, it will show only the splash image of Painter but it won't open it. However if I do exactly the same thing within Windows CMD it will just work fine.

I can imagine this might be a Maya issue and not a Painter issue, but nonetheless I wanted to ask it here as well as at Autodesk forums.

Do any of you know how can I get this working?

Thank you in advance!

this works for me (launching from houdini, on windows):

sbsExePath = 'C:/Program Files/Allegorithmic/Substance Painter/Substance Painter.exe'
subprocess.Popen([sbsExePath, "--mesh", pathToFbx, "--export-path", exportPath], executable=sbsExePath)

Hello Fabricio,

Thank you for your reply, the command should work because it was working for me when I launched it in Maya "vanilla".
I managed to spot what was wrong like one week ago.
I have a python Maya launcher where I set up various environment variables. Apparently launching maya from python seems to mess with cretain libraries of the inner mayapy interpreter and raises a DLL error when I try to execute Substance Painter from that Maya Python script editor for some reason.

Code: [Select]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.

# The error returned was this: return with error (code -1073740791)

Now I am launching Painter from a separate UI that is running in Python3 (the same UI that launches Maya) and it works fine, so I am using maya with command ports to request the UI to launch Painter. I actually prefer this since I can have a running UI that will launch all the needed softwares and can act as a hub to keep track of what is open and what is not.

Kind regards,