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.

--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---

  • ... Beau Garcia
    • ... Shawn Patapoff
      • ... kurian os ™ ®കോപ്പിയടിച്ചാല്©ഗോതമ്പുണ്ട!
    • ... Sylvain Berger
      • ... Shawn Patapoff
        • ... kurian os ™ ®കോപ്പിയടിച്ചാല്©ഗോതമ്പുണ്ട!
        • ... Sylvain Berger
          • ... Farsheed Ashouri
            • ... Beau Garcia

Reply via email to