[Maya/Python] - is OpenMaya C++ related?

Hey folks,

I have a very general question about OpenMaya in Python. What is it?

I’ve tried printing out in the console some variables generated with OpenMaya that is used in a script I’m playing around in, and I get something like this “0x0000000088BD6690” which I know is in relation to machine language which I know is what C++ compiles in.

So is OpenMaya in the context of Python using the same classes as working with Maya in C++?

I’ve been fiddling around in Python now for several months and love it, but already I’ve hit sluggish processing restrictions in the language and am considering opening up a few books on C++ in 6ish months after I get a better handle on Python for Maya.

So what exactly is OpenMaya?

Thanks all!

EDIT: Well I think I answered my own question. Which leads me to more questions about this. http://forums.cgsociety.org/archive/index.php/t-1153773.html <— Where I got the information about this stuff for others looking…

So Open Maya is indeed C++ wrapped in Python.

Does using Open Maya have the same efficiency as coding in C++ or since it’s in a Python wrapper is it also slower?

Would I be better suited to developing a skillset in C++ using Maya API or for general script dev is Python usually the way to go (mixed with Open Maya when need for efficiency)?

Are plugins even developed in Python or are just scripts developed in Python?

My goals right now (and for the foreseeable future) are strictly doing work for CG and I want to learn the best programming solutions to assist in that.

Sorry for the rambles. Thanks!

the OpenMaya module is a swig wrapped interface to the underlying c++ api for maya that can be used in python.

http://help.autodesk.com/view/MAYAUL/2015/ENU/?guid=__cpp_ref_index_html

For most situations you will likely find it is much easier to use pymel and not the openmaya api, unless you are doing really low level stuff that needs speed such as writing your own dag nodes.

yeah, OpenMaya basically allows you to write C++ in python (right down to fun stuff like having to pre-allocate objects and pass pointers, etc). It’s useful for performance-critical applications but otherwise it’s much touchier and harder to write / maintain than straight python. The usual rule is to get things working in cmds or pymel and then port them over when you see a job that is just too slow. If you’re already comfortable with C++ it’s not too bad, but if you are primarily a Python or Mel person then the learning curve is steep and has some odd bumps along the way.

As far as speed is concerned, generally the order from slowest to fastest is: maya.cmds, maya.OpenMaya, maya.api.OpenMaya (Maya Python API 2.0), C++. There is some variation here. Sometimes maya.cmds can be faster, especially if the particular command is doing something complicated behind the scenes. This is because the command is running C++ under the hood.

Generally we use maya.cmds because it is easier to understand the code. We use maya.OpenMaya when it gives us functionality that is not available in cmds. You can use both cmds and OpenMaya in the same code, which is great.

C++ is great if you need the speed. But most of our tools work fine at Python speeds. (As they say, “premature optimization is the root of all evil.”) So we prefer to use Python until those rare occasions when we really need more speed.