Try building an environment for MayaPython with VisualStudioCode

Introduction

Since Maya's script editor is a bonus, I sought to find an environment for writing MayaPython using Visual Studio Code.

procedure

Installation

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

MayaPort settings

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.

Checking the operation of MayaPort

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.

For Python

Execution by command
sendPythonToMaya

Execution by shortcut
CTRL+SHIFT+P (Mac)  ALT+SHIFT+P (Win)

For MEL

Execution by command
sendMelToMaya

Execution by shortcut
CTRL+SHIFT+M (Mac)  ALT+SHIFT+M (Win)

vsc_mp_1.png

Python settings

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

Checking the operation of MayaPort

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.

vsc_mp_2.png

Recommended Posts

Try building an environment for MayaPython with VisualStudioCode
Building an Anaconda environment for Python with pyenv
Various commands for building an environment with Apache
Building an environment for natural language processing with Python
[Python] Building an environment with Anaconda [Mac]
Building an environment for "Tello_Video" on Raspbian
Building an environment for "Tello_Video" on Windows
Building an environment for matplotlib + cartopy on Mac
Building an environment for "Tello_Video" on Mac OS X
Create an environment for test automation with AirtestIDE (Tips)
Building an environment to use CaboCha with google colaboratory
Create an environment with virtualenv
Try an autoencoder with Pytorch
Try building JupyterHub with Docker
[Python] Building an environment for competitive programming with Atom (input () can be used!) [Mac]
Rebuilding an environment for machine learning with Miniconda (Windows version)
Let's get started with Python ~ Building an environment on Windows 10 ~
Create an environment for "Deep Learning from scratch" with Docker
Building a kubernetes environment with ansible 2
Django beginners tried building an environment
Building a virtual environment with Python 3
Building a kubernetes environment with ansible 1
Building a Windows 7 environment for getting started with machine learning with Python
Create an environment for Django x Apache x mod_wsgi with Vagrant (Ubuntu 16.04)
[Pyenv] Building a python environment with ubuntu 16.04
[Definitive Edition] Building an environment for learning "machine learning" using Python on Windows
Build an environment for Blender built-in Python
Procedure for building a kube environment on amazon linux2 (aws) ~ (with bonus)
[Definitive Edition] Building an environment for learning "machine learning" using Python on Mac
Note when creating an environment with python
Building a Python 3.6 environment with Windows + PowerShell
Try fishing for smelt with Raspberry Pi
[Mac] Building a virtual environment for Python
Try sending an email with the Gmail API Client Library for Java
Crawl Follower for an account with Instagram
Building a conda environment for ROS users
Building a Python development environment for AI development
Building an AWS Fargate Service with AWS CDK
Try to generate an image with aliasing
[For beginners] Try web scraping with Python
A story about building an IDE environment with WinPython on an old Windows OS.
Creating an environment for OSS-DB Silver # 1_Create a Linux environment (CentOS7 virtual environment) with VirtualBox/Vagrant
Building an environment to comply with the Python coding standard (PEP8) with Eclipse + PyDev
Let's try analysis! Chapter 8: Analysis environment for Windows created with Python and Eclipse (PyDev)
Selenium + WebDriver (Chrome) + Python | Building environment for scraping
For beginners to build an Anaconda environment. (Memo)
Create execution environment for each language with boot2docker
Building a python environment with virtualenv and direnv
Building an environment that uses Python in Eclipse
Try using conda virtual environment with Jupyter Notebook
Image Processing with Python Environment Setup for Windows
Commands for creating a python3 environment with virtualenv
Introduction to Python "Re" 1 Building an execution environment
[Building a CI environment in 2 hours] Procedure for building a Python Web server with CircleCI and passing an HTTP communication test
Procedure when building Ubuntu as a virtual environment with Vagrant + Virtualbox for LPIC Level 1.
[Cloud9] Try to build an environment with django 1.11 of Python 3.4 without understanding even 1 mm
Try building PySide2
I tried to build an environment for machine learning with Python (Mac OS X)
Procedure for creating an application with Django with Pycharm ~ Preparation ~
Building a Python environment for pyenv, pyenv-virtualenv, Anaconda (Miniconda)
Write about building a Python environment for writing Qiita Qiita