eduardo simioni

Tag: pymel

wing ide with maya on linux

by on Jul.21, 2011, under IDE, Maya

As Jason Parks noted, Wing is definitely a great IDE to work with Python. With OpenMaya and pymel auto-completion together with code debugging it’s everything you might want to script on Maya. Eric Pavey has a great tutorial on how to setup everything, I will just try to resume it with some tips on getting it working on Linux. Some considerations:

  • Sending code works as with Eclipse. You open a port on Maya and send it through a socket. Locally or remotely.
  • Autocompletion works and in Maya 2012 is quite easy to setup.
  • Debug works by importing wingdbstub in your script. Maya to Wing communication function basically the same way as sending code, but on a different port.

Each point is independent from one another and you have to setup each one differently.

Sending code from Wing to Maya.

  1. Open port on Maya
  2. Copy Eric Pavey’s scripts to their folders
  3. Setup hotkeys on Wing’s keymap.normal

To open a port on Maya create a shelf button or add to userSetup.mel either:

import maya.cmds as cmds
    if cmds.commandPort(':7720', q=True) !=1:
        cmds.commandPort(n=':7720', eo = False, nr = True)

Or

// userSetup.mel
commandPort -name "127.0.0.1:7720" -echoOutput;
commandPort -name ":7720" -echoOutput;

You need then two .py files:

wingHotkeys.py – goes into your /.wingide4/scripts in your /home. This saves what you have on Wing on a temp file, opens a socket and communicates with Maya, calling:
executeWingCode.py – which goes under your /home//maya/scripts. It’s called inside Maya by the previous script to run the temp file.

Lastly, you need to bind one or more wrappers into a hotkey in Wing, which calls the functions in wingHotkeys.py. You should do this at /usr/lib/wingide4.0/keymap.normal. Just change one key to ‘Ctrl-P’: ‘python_to_maya()’ or ‘Ctrl-P’: ‘all_python_to_maya()’ for example. The scripts provided above are slightly edited versions of Eric Pavey’s version to work on Linux. The only changes are the socket line, the temp file and the send all to python wrappers.

Auto-completion

  1. Add pi files to Wing Source Analysis

On Wing, under Edit/Preferences/Source Analysis/Advanced/Interface File Path add the directory: /usr/autodesk/maya/devkit/other/pymel/extras/completion/pi. That’s it. For older versions of Maya you might have to find or download the pi files from somewhere.

Debug

  1. Copy wingdbstub.py from Wing to /maya/scripts
  2. Edit wingdbstub.py and set kEmbedded=1
  3. Enable Passive Listen and Kill Externally Launched on Wing
  4. When you want to debug, import wingdbstub in your script

To set this up copy /usr/lib/wingide4.0/wingdbstub.py to /maya/scripts in your /home. Open it and search for kEmbedded and change from =0 to =1.

On Wing, under Edit/Preferences/Debugger/External/Remote activate ‘Enable Passive Listen’ and ‘Kill Externally Launched’. With this you are good to go, but when you want to debug something you need to add this to the beginning of the code you want to debug:

import wingdbstub
wingdbstub.Ensure()

This procedure is also on Maya’s help.

On Windows the folders are different, but these procedures are exactly the same. Both wingHotkeys.py and executeWingCode.py should also work on Windows, the location of the temp file and the socket line depends on the system you are running everything (left two different if’s there just for clarity.)

Leave a Comment :, , , , , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!