This is an updated tutorial – December 2011.
I began using jEdit in 2001 until 2005 and it served me well during that time writing mel, C++ plugins and python for Maya. jEdit became my Maya IDE. But I then discovered Eclipse – and it outshines jEdit.
This tutorial will outline the steps I’ve taken to make Eclipse my Maya IDE. The Maya Editor plugin enables communication directly with Maya for both Python and mel. It also accesses various sets of documentation. Python programming for Maya has been enhanced by adding autocompletion for the Maya API and Pymel. If there are more features you think should be added, please contact me and I’ll see what I can do.
A. Basic resources.
Pydev the open source python plugin for Eclipse http://pydev.sourceforge.net/
B. Maya Editor
This is a plugin for Eclipse that turns it into a Maya IDE. As it is Python-centric, it also requires the Pydev plugin.
- Send the entire contents of an editor to Maya
- Send a highlighted selection to Maya
- Get results back from Maya in it’s own console view
- Anything done within Maya’s own script editor is also echoed in the console view
- Change the port number of the socket at any time
- Open up documentation for Maya’s Python API, Python Commands, Pymel, Qt, PySide, PyQt
1. Unzip the dowloaded file in a temp directory
2. In Eclipse, go to the Help/Install New Software page. Click on “Add” and then “Local” and navigate to the temp directory where the org.eclipse.eclipseMayaEditorProject is
3. In the “Name” section, make sure “Uncategorized” is selected and then click “Next”
4. Allow Eclipse to relaunch and once it’s back, the EclipseMaya toolbar should be visible
5. In Maya, create a new shelf button with the following code or put it in the Startup script
import maya.cmds as cmds
if cmds.commandPort(':7720', q=True) !=1:
cmds.commandPort(n=':7720', eo = False, nr = True)
- Ctrl+Return -> Send editor contents to Maya
- Ctrl+’ -> Send highlighted selection to Maya
- Ctrl+] -> Reconnect Eclipse to Maya
- Port Number – By default, the port number has been set to 7720. It can be changed at any time. Remember to press the “Reconnect Eclipse to Maya” button. This is handy if you have more than one instance of Maya open at once.
- Update Interval: This sets how often Eclipse checks to see if there’s any new text in Maya. It is in time units of seconds.
- The next eight text fields set the location of the various sets of documentation. They can be entered either as web URLs or local file paths depending on where the docs are located. There are 2 user defined options for other documentation sites (If anyone needs more, let me know and I can add more).
C. Pymel Autocompletion (updated Sept. 2011)
Now that Maya comes with pymel, the included docs explain how to get it working with Eclipse. However, there is an easier way that is not explained in those docs. This is by using the “Predefined” option in Pydev preferences. This is a relatively new way of specifying files just for autocompletion.
It requires a directory with files with a .pypredef extension. As of Pymel release 1.03 and Maya 2012, this directory is included.
1. In Eclipse, go to “Windows/Preferences/Pydev/Interpreter – Python”
2, Click on the third tab called “Predefined”
3. Click on “New” and navigate to the pymel “pypredef” directory
4. Click “Apply”
You might have to “refresh” your project to enable the changes or at worst restart Eclipse. Remember to still specify the path to the Maya “site-packages” directory on the “Libraries” path (just like the older method).
D. Maya Python API Autocompletion
a. Typing the first few letters of a class and pressing Ctrl + period ( in the example below an M was typed) brings up the available class options that will complete the class name. Using the up and down keys will highlight the various options. The associated documentation is displayed in a text box to the side.
b. After a class name has been typed, enter a period and the associated functions, attributes and enum options are displayed. The example below shows a typical function with documentation displaying the needed arguments.
c. The Maya C++ API enums are made available as part of the class.
d. Since Python does not have the equivalent of an enum, non-functional classes have been included that collect the associated enum values for enum type so that all possible options are displayed in one place.
F. Setting it up.
The Maya Python API .pyc files do not contain the proper information for autocompletion to function properly. The autocompletion stub files duplicate the classes and methods and attributes structure. They are not functional, but instead include only the associated documentation which is culled from Maya’s own documentation.
This ends up with 2 sets of files– one with the actual functional files and one not functional but with the appropriate structure to allow autocompletion. The stub files are in a single directory and have the extension .pypredef. These are specified with Pydev using the “Predefined” tab.
1. In Pydev, go to “Window/Preferences/Pydev/Interpreter – Python”
2. Click on “Predefined” tab
3. Click on “New” and navigate to the directory containing the .pypredef files
4. Click on “Apply”
Refresh the project and/or restart Eclipse if the autocompletion is not working immediately. Press Ctrl+Space in order to force the autocompletion options if it doesn’t pop up after typing a dot.
Note: If you are also using Pymel autocompletion, be aware that that package also provides pypredef files for the Python API. However, the structure is a bit different and does not provide any of the Maya class/method docs.
The “Predefined” tab is sorted alphabetically and there is a good chance that Pymel’s API files could take precedence – basically clobbering the other API files. I recommend removing the maya.OpenMaya, maya.OpenMayaAnim, etc. files from the Pymel autocompletion directory so that there are no duplicate files.
Further note: Regarding the import paths. I did find there can be slightly different behaviour with the pypredef paths.
The .zip file has a maya/ directory with the OpenMaya*.py libraries inside – this matches the actual Maya library path structure. This is what works for me on Windows.
However, if you are on Linux or if it’s not working for you on a Windows machine, then you can rename the stub files to include “maya.” in front of each library. pypredef then recognizes this when you import maya.OpenMaya* in Eclipse.
D. Hints and Tips
1. The autocompletion feature of Eclipse brings up a list of completion options and a documentation window for any info that exists for the selected option. By default, the yellow doc window is displayed as a small square and for some options, the text doesn’t fit and really isn’t that readable. But if you click inside the yellow window, it gets focus and a scrollbar appears. This can be used to display all the available docs. Also, dragging the bottom of the doc window will increase the viewing area; this new size is then remembered each time the window is displayed.