/ MAYA, SCRIPTING

PyMel Development: With VSCode

Step 1: Configure Visual Studio Code

Install Visual Studio Code

Install Python Plugin

Step 2: Prepare Maya

From the Installation Guide from SendToMaya:

To enable ports at startup create a file named userSetup.mel in the following folder:

Windows: :\Documents and Settings\My Documents\maya\scripts Mac OS X: ~/Library/Preferences/Autodesk/maya//scripts. Linux: ~/maya//scripts. (where ~ is your home folder) In the userSetup.mel file add the following

commandPort -name "localhost:7001" -sourceType "mel" -echoOutput;
commandPort -name "localhost:7002" -sourceType "python" -echoOutput;

Step 3: Autocomplete

Download Maya Devkit

Autodesk Maya Devkit (Important: Devkit available for all Operating systems, select the correct one before clicking download)

Extract the package to the C:/Program Files/Autodesk/Maya2018/devkit directory.

Configure VSCode

Open the Settings and add following lines (Adjust to your OS):

(...)
"python.autoComplete.preloadModules": [
"C:/Program Files/Autodesk/Maya2018/Python/Lib/site-packages",
"C:/Program Files/Autodesk/Maya2018/devkit/devkit/other/pymel/extras/completion/py"
],
"python.autoComplete.extraPaths": [
"C:/Program Files/Autodesk/Maya2018/Python/Lib/site-packages",
"C:/Program Files/Autodesk/Maya2018/devkit/devkit/other/pymel/extras/completion/py"
],
(...)

Step 4: Test Setup

  1. Open Maya and VSCode
  2. In VSCode create a file test.py
  3. Write following lines:
    import pymel.core as pm
    pm.sphere()
    
  4. Press CTRL-ALT-M
  5. Check in Maya if a Sphere was created.