mooky
January 10, 2013, 3:32pm
1
So I am trying to source some scripts that are inside a folder outside of the normal maya script folder.
If I was to do it in Mel it would be something
source “/Users/myName/Documents/folderWithAllMyScript/myScript01.mel”;
source “/Users/myName/Documents/folderWithAllMyScript/myScript01.mel”;
Is there anyway to do this in python?
Right now all I have is this. Not sure where to really go from here.
import sys
syspaths = sys.path
sys.path.append( ‘/Users/myName/folderWithAllMyScript/’ )
#insert your path of cause
for path in syspaths:
print path
Unless your code doesn’t work right, you just import the module at that point. IE, you’re done.
capper
January 10, 2013, 6:26pm
3
If it’s a directory you’ll be wanting to import scripts from often, you can add it to the PYTHONPATH variable in Maya.env as well. That will make it accessible whenever maya loads (so you won’t have to use sys.path.append)
Here is what I use, just a little more logic
import sys
pth = 'yourPathHere'
if not pth in sys.path:
sys.path.append(pth)
#main chunk of code
#to clean up at end
sys.path.pop(sys.path.index(pth))