What is Python in Maya

The original language in maya it is mel, its been quite some time that maya acccepts code written in python. Mel is an structured programming language, that has some limitations when you start writing larger programs. The syntax is not that simple and it is prone to errors. Python on the other hand offers an object oriented programming paradignm, a simpler sintax, with a whole set of libraries with tools ready to be used.

Currently Autodesk provides multiple frameworks to develop maya tools with python. This frameworks are pymel

maya commands, Mayaapi, and the Maya-api2

Each one has different characteristics and I will try to describe the advantages and dissadvantages of each one of them.

Maya.cmds Maya commands is literaly the port from Mel in to python it works with strings and returns strings for most of the functions, and it might be the eassyest way to switch from Mel to Python.

pymel, it is an attempt from luma pictures to write a more pythonic way of maya cmds, it returns pymel objects that are linked to the C objects in maya, so it really returns objects that can interact with the scene, and that are not name dependent. Some people complain about the slowlyness of pymel but on my experience writing code is very fast and can be a powerful tool to develop, as long as you are not dealing with big ammounts of information, like vertex weights in a high poly geometry.

Maya APi It is the first attempt of autodesk to emulate the maya C++ api but in python. It is supposed to be the way to have fast operations to handle large ammounts of data in a fast way. One of the cons of the maya API 1 is that it was done in a very C++ way, where you need to provide empty objects to the functions, to get result values, it is complicated to use and as we will see with the API2 it might not be my first option to develop with the API.

Maya API 2. This is the second attempt of autodesk to get a more pythonic way of doing things with similar function that in the C++ api.

It is faster to execute and develop on the Maya API 2 than in the Maya API. At the moment I am not aware if it contains all the functionality that the API but at some point I remember it didn’t and it still was in development.

Long story Short, I am very used to write fast iterations of code with pymel, most common code I interact with is maya.cmds, and whenever I need to write something that is handling large amounts of data, like skinweights or geometry vertices, I am doing it with maya.API2