Since Maya's script editor is a bonus, I sought to find an environment for writing MayaPython using Visual Studio Code.
Visual Studio Code First, install Visual Studio Code. Of course, if you have one, omit it.
Python Visual Studio Code is a collection of useful features for Python development. There is an extension called Python, so install it.
Press F1 on Visual Studio Code and enter the following to install.
ext install python
MayaPort Then send the script entered in Visual Studio Code to Maya for execution There is an extension called MayaPort, so install it.
ext install mayaport
First, set up MayaPort. I made it with a Python file, but I need to prepare the following file.
userSetup.mel
commandPort -name "localhost:7001" -sourceType "mel" -echoOutput;
commandPort -name "localhost:7002" -sourceType "python" -echoOutput;
userSetup.py
import maya.cmds as cmds
cmds.commandPort(name=":7001", sourceType="mel")
cmds.commandPort(name=":7002", sourceType="python")
Once the files are ready, place the userSetup file in the following location. Just in case, Visual Studio Code will be restarted. The preparation is now complete.
Windows: <drive>:\Documents and Settings\<username>\My Documents\maya\<Version>\scripts
MacOSX: ~/Library/Preferences/Autodesk/maya/<version>/scripts.
Linux: ~/maya/<version>/scripts.
After starting Maya, return to Visual Studio Code and prepare the following test file.
connect_test.py
print "connected!"
Press F1 to open the command palette and enter the following to launch MayaPort.
mayaPort
Now you are ready to send the preparation script. After that, in the case of the command palette, enter the following.
Execution by command
sendPythonToMaya
Execution by shortcut
CTRL+SHIFT+P (Mac) ALT+SHIFT+P (Win)
Execution by command
sendMelToMaya
Execution by shortcut
CTRL+SHIFT+M (Mac) ALT+SHIFT+M (Win)
Change two Python settings.
//Insert the settings in this file to override the default settings
{
"python.pythonPath": "/Applications/Autodesk/maya2015/Maya.app/Contents/bin/mayapy",
"python.autoComplete.extraPaths": [
"/Applications/Autodesk/maya2015/devkit/devkit/other/pymel/extras/completion/py"
]
}
python.pythonPath Specify the path of the Python command.
MacOSX: /Applications/Autodesk/maya2015/Maya.app/Contents/bin/mayapy
python.autoComplete.extraPaths Specify the file to use for autocomplete. By setting this, candidates will be displayed in Maya commands.
MacOSX: /Applications/Autodesk/maya2015/devkit/devkit/other/pymel/extras/completion/py
However, it takes a long time to display candidates for maya.cmds ... Probably because the file of maya.cmds in the above directory is abnormally large.