Learning How Best to Python in Maya 2017

I’m in the process of tooling up on Python in Maya 2017. I played around a bit on the side with PyMEL way back in 2011. At that time, PyMEL (even having not yet received Autodesk’s blessing) was considered to be preferable to the built-in Maya Python API (v1.0) in many cases. However now that Maya’s Python API 2.0 has (presumably) hit a point of completeness / maturity, how does the latest version of this new-ish API compare to Pymel?

I’d love to hear any recommendations that you gals / guys might have regarding the best application of really any of the scripting interfaces / APIs that Maya offers and any advice that you might have concerning what constitutes a good starting point for someone such as myself that is coming back to Maya and Python after a long hiatus (proceeded by a relatively brief bit of tinkering).

I’m currently considering starting off with one of the following books:

https://www.amazon.com/Maya-Python-Games-Film-Reference/dp/0123785782/ref=sr_1_1?ie=UTF8&qid=1496945666&sr=8-1&keywords=maya+python+for+games+and+film
https://www.amazon.com/Practical-Programming-Python-Robert-Galanakis/dp/1849694729/ref=sr_1_1?s=books&ie=UTF8&qid=1496951455&sr=1-1&keywords=practical+maya+programming+with+python

Both books look phenomenal, but I’m a little concerned about the age of the first book (having been written prior to the introduction of the Maya Python 2.0 API).

Regarding Rob’s book, the fact that it is at least somewhat PyMEL-centric appeals to me, but I can’t help but wonder if it makes more sense to start off with Maya’s out of the box Python implementation (probably v2.0) first.

As always, I’d appreciate any wisdom that the TAO community has to share. :relaxed:

1 Like

I’ve got both books and kind of viewed them as rather complementary.

As for how well they’ve aged, any of the examples using API 1.0, PyMEL, or plain old cmds should continue to work (barring weird bugs) as those are pretty forwards compatible.

The Qt related examples however will require modification because 2017 is when Maya jumped from Qt4 to Qt5, and introduced PySide2 with it’s whole new namespace layout.

And it goes without saying that they both lack any major examples of API 2.0, as it wasn’t really usable when they were written.

Those books are still applicable today. Both give you insight on how to thing about maya coding in general.
While API 2.0 has gotten better, I still find myself using pymel purely do to style and coding practice. I also find that pymel can teach you more about the nodes you’re working with and their inner workings. I only use api 2.0 if I need speed (iterating over giant meshes for example) and it still feels too verbose at times.

Right on. Thanks for the speedy response and the great info., R.White. With the Qt / Pyside changes that you’ve highlighted, I suppose that now’s a rather good time to hop into the mix (my assumption being that it’ll likely be a while until either Qt or PySide are next upgraded). :grinning:

Yeah, the Qt5 change should be pretty stable going forward. And should be a lot easier to deal with if you’re not trying to support both simultaneously, though there are some good compatibility libraries out there that help with that if it becomes a thing.

Thanks, Sariel. I’ve seen others express similar approaches that involve utilizing PyMEL anywhere in which the execution speed of PyMEL is adequate (or simply for prototyping purposes) and then moving on to either the Python 2.0 or C++ APIs in cases where more speed is needed.

2 Likes

Are there any good resources for learning Maya Python 2.0 API? I’m currently working my way through Practical Maya Programming with Python. I began learning MEL, cmds and now pymel, but I’m having a hard time finding an entry point to 2.0. There seem to be some decent ways to learn API 1, like Chad Vernon’s CG circuit videos and the book above. Do I dive into 1.0 and figure 2.0 after or can I start there?

I would start with the API 2.0. It is a cleaner more pythonic API, while it isn’t a complete replacement yet, it gets closer with every version.

Some semi-decent examples can be found in the devkit, they all start with ‘py’, and can be found in devkitBase\devkit\plug-ins\scripted.
You can actually compare them to the API 1.0 versions by checking for a file with the same name minus the ‘py’ prefix.

You also have to download the devkit separately from autodesk.

1 Like

And, unfortunately, there’s not much good high level documentation aside from the examples. The api level docs are fine, they tell you what all the functions are and what they do for a given class. However they don’t really tell you how to “do things” – which classes you’ll need or what order of operations to try. Some of that can be gotten from the examples, and some of it is just absorbed by experience… alas…

2 Likes

The first book is very good, but it’s more of a quickstart than a continuing reference.
There aren’t any books that really cover the use of PyQt/PySide in any real depth.
Especially the whole Qt4 v Qt5 issue, and Maya’s module system (for handling different versions and different operating systems when deploying tools)
The internet is still the best resource for information.
Each new release of Maya seems to throw in new issues that the books cannot anticipate.
Start on those books, but that’s still the beginning of your journey.
And think about getting some general Python books too. Python can do some really clever things but it takes a long time to learn how to take advantage of the language.
For example, neither of these books explain well how to build a solid class and how to get the most out of properties and accessors. Or any in depth discussion about module strategy. Again the first book provides a primer, but it’s still very basic.

1 Like