04/12/2009

Maya API: Where to start!?!??!?

My colleague asked me a couple weeks ago “What in your opinion would be a good place to start for a Maya application user who wants to get into scripting / developing etc.” which is such a great question and here is my guidance…

Goal:

Learn Maya API; however you are mostly new to programming as well…

There are two sides of the coin (okay maybe there is more than that but I’m going to only address the two sides):

Side 1: Learn the Programming Languages First:

To gain the fundamental core knowledge and concepts of programming, one could say leave out the Maya component at this point in time, and just focus on learning the programming language: C++/Python.

The benefit about doing this is there are so many resources available to learn a programming language, books, DVD’s, courses at school, websites, etc, so you not limited on the different teaching styles you are bound to find material that matches your way of learning.

Once you feel savvy and confident with the language then add in the Maya API component, and things can start coming together nicely.

But do we really have the time for this type of learning leisure!??!? Probably not L

One could also argue that the code you have worked on up to this point may not be relevant to your final goal and there for not as productive as it could be.

These are the books I use regularly, I can’t lie I don’t diversify much I really, really like them! I am a bit of a paper person, sorry environment, but I love having text books to look things up in, however I do believe these are available electronically, and I am told the kindle is very book like, so to each their own.

The key to this learning path is ‘Curiosity’! If you are not curious about things, you will take things for granted without really learning why or how they work, and when things get complex in the Maya API, which they do get very fast, you will have unexpected results. The beauty of the Maya API is it is tremendously flexible, but with flexibility comes the ability to do what you want, incorrect or correct, and incorrect can become a frustrating problem.

This route is even more time intensive then the last because you are learning the language, the API tool kit and the API architecture for how Maya really works under the hood. Up to this point as a Maya user, you may have only tinkered in the Maya API architecture, mainly with the Hypergraph and the Maya Nodes.

Here is the fantastic book on the Maya API (outside the Maya docs, of course J), I haven’t been able to buy it in a digital copy, so if anyone knows where it’s for sale digitally let me know, because lugging this book to trainings I am delivering across the world can get… heavy!

My Favourite Books:

Complete Maya Programming: An Extensive Guide to MEL and the C++ API by David Gould

Random Other Coins: What is the right Maya Programming Language for you?

In Maya there are two different access levels what we call “scripting” and what we call “API”, yes I agree this is quasi confusing, because the API now has a scripting language that can access the API…I made this lovely Christmas themed PowerPoint to help visualize it how it all fits in (Thanks Microsoft):

SCRIPTING CHOICES: Python vs. MEL

I would recommend to anyone starting out to probably to start with Python (here is some more information on Python), as the Learning Python book says “Compared to other programming languages, the core Python language is amazingly easy to learn. In fact, you can expect to be coding significant Python programs in a matter of days…”.

The benefit of MEL is that any actions done in the Maya UI, a MEL command that does the same action is outputted to the Script Editor….but this is okay because all the MEL and Python scripting commands named the same thing just different syntax so you can continue to use Python and use the MEL output command functionality as guidance.

The other benefit of Python is it’s not limited to Maya, which is a huge advantage.

API CHOICES: Python vs. C++

Choosing your API language isn’t really a Python vs. C++ type of choice (I only did that to have my titles consistentJ). It’s more of a new to programming? Start with Python which is more of nicer transition from Python Scripting to Python API, then when Python isn’t meeting your needs for the API, two main reasons would likely be performance and discloser of the code, you can then starting learning C++, this will be a could be a steep learning curve at first but if you’re getting pretty savvy with Python and really understanding object oriented programming then it might be a very nice progression for you.

I kind of switch between the two, if I have to test something or mock something up, I most likely going to do it in Python, I find it way quicker.

My Personal Learning Experience with an Autodesk API:

I am going to share with you my personal learning experience on Autodesk MotionBuilder SDK (I know this is a Maya blog, but it’s relevant I swear!). I have the luxury of being a programmer by education/work experience so learning C++ and Python was not my challenge. My challenge was not knowing the MotionBuilder SDK and even worse not knowing MotionBuilder application left me in a bit of a pickle when I first started at Alias (now Autodesk). My team at the time said “okay Kristine we are going to teach a course on the MotionBuilder SDK, you have to create these 4 assignment scripts for the class, you have one week…go…”(okay maybe they gave me longer than a week, but this is my story so I can tell it how I want ;)) After having a mini freak-out, and way too many overtime hours, and most importantly sitting with my colleague Kevin with me asking questions like “what’s a character, what’s an actor, what’s retargeting” the moral of the story is this deadline whipped me into shape, and I came out the other side of it having had this amazing crash course in the MotionBuilder SDK and being pretty darn savvy at it, if I don’t say so myself. This might not work for some people, but for other it might, so maybe tell you boss you are going to hand in a plug-in by a certain date, and since you don’t want to miss deadlines (wink, wink) you’re going to work your butt off to complete it on time, I don’t fully endorse this approach since it messes with the work life balance we’re all striving for, but if you see that it may work for you, it’s worth a try J

have you got any resources on how maya's wrap deformer works? is it multithreaded/hard-coded?
im using c++ daily 6 years now, stl and boost libs 3 years but im afraid maya's api is *not* that friendly for developers.