Integration Autodesk Maya with external editors for working with data and scripting

cover_101.png

While working on 3D models and complex scenes, CG artists often access data in open formats. An important advantage of Autodesk Maya, in comparison with other computer graphics programs, is the open scene data format and the universal scripting language MEL, as well as tight integration with Python.

A Maya ASCII file (*.ma) is a MEL script with a description of all nodes and links between them in the scene, attribute values, and program parameters.

Maya 2022.2 with open scene and Script Editor.Maya 2022.2 with open scene and Script Editor.

Maya 2022.2 with open scene and Script Editor.

You can communicate Maya with an external application based on ports and software pipelines, which is configured using the External Communication options in the program settings (Preferences window).

Simple, but highly extensible IDE’s, with the ability to integrate with compilers and operating system tools, have gained great popularity.

For myself, I chose two popular editors:

  • Sublime Text 4
  • Visual Studio Code

Several useful extensions have been created for selected editors to help them integrate with Maya and Arnold Renderer. I'll talk about extensions for Sublime Text and VS Code that make it easier to work with MEL and Python scripts.

Extensions for Sublime Text

All Sublime Text extensions can be downloaded from Package Control or from GitHub. You can use a simple search on the Package Control website to access and get information about the required extensions.

The Package Control website, describing the MayaSublime extension.The Package Control website, describing the MayaSublime extension.

The Package Control website, describing the MayaSublime extension.

The MayaSublime extension allows you to edit *.ma, *.mel and *.py files in Sublime Text and send scripts directly to Maya by specifying a port in the commandPort parameter.

A useful feature in MayaSublime is Send to Maya, which sends selected text to Maya using commandPort.A useful feature in MayaSublime is Send to Maya, which sends selected text to Maya using commandPort.

Script for configuration commandPort in MayaScript for configuration commandPort in Maya

A useful feature in MayaSublime is Send to Maya, which sends selected text to Maya using commandPort.

Using the extension simplifies the development of tools for automating routine tasks, which is important when working with complex projects that require tool development and debugging.

By working with an external editor, you can eliminate the risk of data loss in the event of an error or closing the program without saving the created scripts.

In addition to MayaSublime, I use two other useful extensions: Sublime Open Shading Language and PixarUSD.

The Sublime Open Shading Language extension allows you to create material and procedural texture shaders in OSL and compile them for your chosen rendering engine.The Sublime Open Shading Language extension allows you to create material and procedural texture shaders in OSL and compile them for your chosen rendering engine.

The Sublime Open Shading Language extension allows you to create material and procedural texture shaders in OSL and compile them for your chosen rendering engine.

The Open Shading Language is used to create material and texture shaders without depending on a specific render engine.

You can create a shader for Arnold Renderer and bring it with minimal modifications to V-Ray or RenderMan. An example of an OSL shader is the Autodesk Standard Surface used in 3ds Max and Maya.

A very useful feature of the Sublime Open Shading Language extension is a toolkit for debugging and compiling written shader code. This greatly simplifies working with OSL shaders and tests in the chosen render system.

The Sublime Open Shading Language extension allows you to create material and procedural texture shaders in OSL and compile them for your chosen rendering engine.The Sublime Open Shading Language extension allows you to create material and procedural texture shaders in OSL and compile them for your chosen rendering engine.

PixarUSD extension for Sublime Text.

With the growing popularity of the Universal Scene Description (USD) format developed by the PIXAR animation studio, the need for convenient work with it in external editors has increased.

Exporting the model to USD format can be done from Maya, and in Sublime Text you can work with the data saved in the USD file. Then, the model can be imported back into Maya or 3ds Max.

Extensions for Visual Studio Code

If you prefer Visual Studio Code, the IDE also has several extensions that allow you to work with Maya data, OSL shaders, and the USD format.

The Visual Studio Code editor with a Maya scene file open and a terminal running (on the right) that launched Maya.The Visual Studio Code editor with a Maya scene file open and a terminal running (on the right) that launched Maya.

The Visual Studio Code editor with a Maya scene file open and a terminal running (on the right) that launched Maya.

MayaCode extension I use in VS Code. It can be downloaded from the VS Code extensions page, or directly from the IDE itself, under Extensions. If you type Maya in the search, you will see several extensions that support Maya. I prefer MayaCode as the most functional.

Extensions for working with Maya, OSL and USD in Visual Studio Code.Extensions for working with Maya, OSL and USD in Visual Studio Code.

img_109.png

Extensions for working with Maya, OSL and USD in Visual Studio Code.

The MayaCode extension supports syntax highlighting for Maya scenes (*.ma), MEL scripts (*.mel), and Python (*.py) formats. Also, the extension supports a number of important functions, such as autocompletion in the process of writing MEL and Python scripts, displaying snippets, sending selected text to Maya based on commandPort.

Autocomplete while typing and displaying snippets defined in MEL script file in Outline panel.Autocomplete while typing and displaying snippets defined in MEL script file in Outline panel.

Autocomplete while typing and displaying snippets defined in MEL script file in Outline panel.

Similar to MayaSublime, to send a dedicated script block, you must define a communication port between Maya and VS Code. A simple MEL script is provided for this, which must be executed in Maya Script Editor.

 

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

 

Just like Sublime Text, you can extend Visual Studio Code with OSL and USD support. But unlike Sublime Text, in VS Code, OSL code cannot be compiled and debugged. Therefore, I recommend using Sublime Text with the Sublime Open Shading Language extension to work with OSL.

The OSL and USD extensions add support for Open Shading Language syntax highlighting and the Universal Scene Description format to Visual Studio Code.The OSL and USD extensions add support for Open Shading Language syntax highlighting and the Universal Scene Description format to Visual Studio Code.

The OSL and USD extensions add support for Open Shading Language syntax highlighting and the Universal Scene Description format to Visual Studio Code.

Here are a few key benefits of working with external IDEs and text editors:

  • Access to the terminal and system commands
    • UNIX Pipeline Support
  • Debugging tools
  • Support for connecting compilers
  • Pipelines support
  • Custom Extension Development and Automation

In the next post, we will go back 21 years and get to know 3ds max 4! It will be very exciting! 🙂