Hello,
Here is a video I made discussing the various types of Python available in Maya. And when to use which API.
A lot of people still use cmds, and haven't discovered the advantages of Pymel yet. Hopefully this will help spreading the word.
The official Autodesk intro is also great at comparing both of them.
And I go over some examples in my video.
https://www.youtube.com/watch?v=xniqGsWb3uo
Let me know what you think, if you agree/disagree. Would be great to get more people talking about Python in Maya instead of MEL.
incase above embed doesn't work here is the direct link:
https://www.youtube.com/embed/xniqGsWb3uo
Replies
The real benefit is that developing tools with PyMEL is just faster than it is with Maya API (iteration time is faster). Your code is more readable and it's easier to maintain by more people +easier for companies to hire Technical Artists who can continue maintaining and developing pre-existing tools. (Bottom line here is that most TA's can't even read C++, and/or they struggle with wrapping their heads around how the Maya API work - even if written in Python using the OpenMaya library).
Also: PyMEL has an object-oriented approach and it's big amount of utility functions means you write less code. Getters and setters for pretty much everything and the fact that everything is an object and not a string is just superior to the alternative of writing verbose code with the -edit flag on every single command, or doing string parsing and other silly workarounds (which you will do when working with Maya.cmds)
OpenMaya and the Maya API is real useful - especially for things like mesh processing or any other case where you wanna loop over a big amount of mesh components (like retrieving UV shells or copying vertex colors between channels, or making a deformer). In such cases then it doesn't matter if you chose PyMEL or Maya.cmds - both alternatives are slow in comparison and should be avoided at all costs.
No the best approach is to write your tools in Maya.cmds or PyMEL, release an MVP of your tool to the Art team and then get feedback from them while you work on optimizing the slower parts - like getting rid of unecessary selection-behavior or string processing. Then you replace those parts in your Python code with some OpenMaya-based functions for v2 of your tool - something that can use the MItMesh -iterators and loop over component indices instead of dealing with dumb strings. That is a good, iterative approach that is favorable in production environments. Heck even if you know from day 1 that what you need is a C++ plugin I still believe that developing with Python and OpenMaya is quicker for the first few versions of the tool: it's easier to test things live in the script editor than it is to compile a build in Visual Studio every time you do a tiny change.
I don't see readability as an issue, if the implementation is difficult to read, you can always wrap up stuff yourself by writing your own functions or classes and comment on what you are doing.
Any procedure that instantiates and manipulates a lot of PyNodes is going to take a hit, that can be significant depending on what the task is. I know a lot of folks who love pymel, but personally think the cost outweighs the benefits.
As you mentioned about setting up an MVP or proof of concept to show the team prior to writing it the "real" way: if using cmds is 10-20x faster, doesn't it make sense to go with that for testing out code? Processing vertices or joints can be seconds as opposed to minutes without having to write C++ or Open Maya. If you are experimenting with ideas, that can be a big deal. There are a number of sites that discuss the difference with performance in length. I think it's totally worth discussing the pros and cons of pymel. At the end of the day, do whatever works for you.
http://patrickvfx.blogspot.com/2017/04/pymelcore-versus-mayacmds.html#.X0rBRchKiUl
I don't want to beat a dead horse, but I figured I would add some of my own speed comparisons... for science. I'm using Maya 2018 btw, maybe Pymel is way faster in newer versions.
There's no doubt that pymel is slower - noticeably so in many situations - but if you're really interested in speed you don't want to be using python or even doing the work in Maya if you can avoid it.