Custom scripts folder to house .py files.

Custom scripts folder to house .py files.

deven.saxenaP7BD5
Enthusiast Enthusiast
529 Views
1 Reply
Message 1 of 2

Custom scripts folder to house .py files.

deven.saxenaP7BD5
Enthusiast
Enthusiast

Hello,

 

In my current setup, I have a master folder that has 10 different .py files along with __init__ file. I use Python.ExecuteFile in order to run my mainLaunch.py file and a Pyside Ui is generated. Depending on what the user clicks on, the corresponding .py file is imported/loaded. 

At the time of development, I added a PYTHONPATH system environment variable that had the path of the folder that houses all my scripts. This worked well and I could see my scripts folder when I did sys.path print.

 

The issue is that not everyone in the team has python installed and as a result, this approach might not work for everyone. 

What would be the correct/efficient way of doing this? Coming from Maya we have a userSetup.py/maya.env where we can append sys.path. This will make sure that the scripts folder is accessible and Maya scans for scripts in that folder when needed.

 

Ideally, I would love to add my scripts directory to the system environment variable and have Max look into it for scripts. I also don't want to copy scripts into program files.

 

It looks like this( https://help.autodesk.com/view/3DSMAX/2022/ENU/?guid=GUID-D7D373FD-CA78-4986-AB3D-B1E25F2A37CC ) is what I should be using but I am not able to get it to work. 

 

 

0 Likes
Accepted solutions (1)
530 Views
1 Reply
Reply (1)
Message 2 of 2

deven.saxenaP7BD5
Enthusiast
Enthusiast
Accepted solution

Looks like sys.path.append worked. The only drawback is that it keeps adding the temporary path every time the script is triggered but is only till the point max gets reset, so may be not that bad?

 

import sys
sys.path.append('C:/Users/pathToScriptsFolder')

 

0 Likes