![]() |
| Maya 2011 new features |
- Custom syntax highlighting.
- Collapsible Code.
- Regex Assistance.
- File management, versioning, sharing is easier.
- Runs on an independent process.
Again Python has the benefit over MEL in that it is an independent, open-source language. Therefore IDE's are readily available. Eclipse + PyDev [open-source], Komodo [commercial], PyCrust [commercial], etc. In addition every Python interpreter comes with a bare bones editor called IDLE. Install either version 2.5 or 2.6 (post Maya 2010). http://www.python.org/download/ To launch the IDE go to Start > Python > IDLE. You can also launch it through a shell using:
python C:/Python27/Lib/idlelib/idle.pyYes, you are using a Python application to write your own Python scripts. Once the Tk Python shell opens go to File > New Window. Here you can type your code as if you were using Maya's Script Editor. You will want to save your file to ~\Users\Paul\Documents\maya\scripts [Windows] or ~/Library/Preferences/Autodesk/maya/scripts [Mac] with a .py extension.
Then in order to execute this file from Maya type:
import filenameOnce the file is imported successfully and you want to make changes you will need to run:
reload(filename)There may be times while debugging when it may be more convenient to execute portions of your external script from Maya. To interact with imported objects you must type the filename . variableName.
import HelloWorld print HelloWorld.mySting #call a variable defined in HelloWorld.py HelloWorld.myFunction() #call a function defined in HelloWorld.py*Maya can read Python documents created after Maya has launched, but cannot read new MEL files until it has been restarted.


