This is my setup:all my scripts are located on my server //myServer/pythonScripts in the maya.env file I have added this path to the python path PYTHONPATH = //myServer/pythonScripts
in this folder I have sub folders (also called packages) animation/ modeling/ rendering/ etc. the root folder (pythonScript folder) and all the sub-folders have a __init__.py file (an empty file name __init__.py) , this basically tell python that these folders should be included by the import command so if I want to use a function located in a script from the animation sub-folder (animation package) I type the following: from animation import animFunctions or if i want to acces a function located in a script located in the modeling sub-folder I type: from animation import script01 then I can call the functions of these scripts animFunctions.function1() or script01.funciton1() alternatively I can also rename the package in the import function. from animation import animFunctions as anim then call the function using the name anim.function1() I find this setup simple and clean, each scripts are located in a corresponding sub-folder yet they are all accessible and all this with only one PYTHONPATH setup. Hope this makes sense On Tue, Nov 4, 2008 at 1:43 PM, Shawn Patapoff <[EMAIL PROTECTED]>wrote: > What does the __init__.py do for Maya outside of a class? I several custom > PYTHONPATH setup and I just use sys.path.append() to add any custom script > paths in my userSetup.py. Any other workflow would be great to hear. > > On Tue, Nov 4, 2008 at 9:33 AM, Sylvain Berger <[EMAIL PROTECTED]>wrote: > >> First you need to make sure that the path where the python file is save is >> in your python path, you can usse your computer environment variable or maya >> maya.env file. I prefer using the maya.env file (located in your the maya >> pref folder) >> >> Then let's say the python file is named myPythonFunctions.py and in this >> file you have the doStuff() function >> >> in Maya you type: >> >> # import all the function contained in the python script in the main >> namespace >> import myPythonFunctions >> # make sure all the functions are up to date (this let's you edit the >> python file in an external editor without having to reload maya to update >> the script) >> reload(myPythonFunctions) >> >> # call the doStuf function >> myPythonFunctions.soStuff() >> >> Hope this helps >> >> >> I always use this method, I edit in Eclipse and simply import, reload and >> execute my functions without having to connect Eclipse with Maya. >> I usually create a shelf button containing the 3 lines, edit the script in >> eclipse, save, go in maya and hit the shelf button to run the command, go >> back in eclipse, edit some more, save ... you get the idea :) >> >> Good luck >> >> >> On Mon, Nov 3, 2008 at 10:42 PM, Beau Garcia <[EMAIL PROTECTED]> wrote: >> >>> Hi, >>> Sorry to ask such a basic question, but basically i want to source and >>> run a externally stored python script. Similarly to using "source >>> melScript.mel; melScript;" commands in Mel. Ive tried doing this by saving >>> the .py file as the same name as the main function used and then placing it >>> in a scripts folder. Then after re-loading maya, I tried to run the function >>> name , but no luck. Any help would be great. Thanks >>> >>> Beau >>> >>> >>> >> >> >> -- >> They say, "Evil prevails when good men fail to act." What they ought to >> say is, "Evil prevails." >> Nicolas Cage as Yuri Orlov in Lord of War. >> >> >> >> > > > > -- They say, "Evil prevails when good men fail to act." What they ought to say is, "Evil prevails." Nicolas Cage as Yuri Orlov in Lord of War. --~--~---------~--~----~------------~-------~--~----~ Yours, Maya-Python Club Team. -~----------~----~----~----~------~----~------~--~---
