You can keep your python script at any of these location that you need to import later:
Here is the solution I came up with when I was working on my Set Imageplane for maya personal project.
In the line 5. I initialized a a variable to check if the file exist , the fileexist stores Boolean value True or False, and since each variable declared in the for loop contains the path of each location that can have python module so the code in the 5th line, os.path.exists returns True or false and when the fileexist condition is met, I sourced in my old mel script that i kept in my documents/Maya /<version>/scripts folder, so it gets sourced in using the source method. You would probably import pymodule, since I knew the mel script I have distributed is going to be either of the above location that gets listed by sys.path, I took advantage of it. The print statement in the 6th line prints out the paths in stored in each variable with search result(True or false). See figure.4 below, the result in my case. The autSetProj sets the project automatically if its not set which inturn gives default directory to my file dialog to get to sourceimages where the artist must store his/her imageplanes which means he has least steps to take rather then browsing to the location.
| I hope you enjoyed reading my tip on sourcing in python or mel script from withing the python script and where to keep the python scripts that you have to use in the maya to simply import and run. I am looking forward to hear comments, question from you. |