Maya’s programming languages
It seems like there are more and more posts, queries, and threads about Maya’s different scripting languages. I figure it’ll be nice to have a nice listing of the languages, their benefits and uses.
Here is a quick breakdown:
MEL:
- Entire application is basically written in MEL
- Super simple, easy to learn
- Very limited in data-structures and code complexity
- Most training material available
- King of the 3D scripting languages, really
maya.cmds:
- Python syntax of entire MEL command base
- Still command-based as opposed to OOP-based
- Can import any python module
- Has access to most of Maya API as python syntax
- Simplest, safest, most robust option for Maya
PyMEL:
- ‘Pythonic’ wrapper for all of maya.cmds and MEL
- True OOP
- Code scales well
- Tons of utility functions
- The sweet spot, for sure
MRV:
- ‘Pythonic’ wrapper for C++ API
- True API formatted syntax
- For programmers who’d like to prototype faster
API:
- C++ language for much of Maya
- Create custom locators, deformers, nodes, etc.
- Not intended for scripting procedures
- The serious-end of things
There are performance issues with each language but in my experience, speed is not an issue in all but a few cases (iterating through lots of verts or polys, etc.)
The great thing is that you can actually use all of these languages together, at the same time, in the same script if you want to. A python script can import maya.cmds and PyMEL (though they stomp on each other a bit, so you’d have to import into seperate namespaces if you really wanted to use both), PyMEL has a mel call for special mel cases, both have access to most of the API via python; and you can import MRV too, if needed.
For noobs, I’d hop straight into maya.cmds and then expand your knowledge out to the other options as needed.
Ping me for glaring omissions, thanks.
似乎有越来越多的关于Maya不同脚本语言的帖子,如查询或线程。我认为,有一个语言编程对比列表会很有好处,关于他们的好处和用途。
以下是快速细分:
MEL:
- 整个应用程序基本上都用MEL编写;
- 超级简单,易学;
- 数据结构和代码复杂性非常有限制;
- 大量的培训材料可供使用;
- 是最好的3D脚本语言,真的;
maya.cmds:
- 整个MEL命令库的Python语法化;
- 仍然是基于命令的,而不是基于OOP面向对象的;
- 可以导入任何python模块;
- 像python语法一样可以使用大部分的Maya API;
- 对于Maya编程是最简单,最安全,最强健的选择;
PyMEL:
- 是所有maya.cmds和MEL的python风格化“Pythonic”包装(wrapper);
- 真正OOP面向对象编程;
- 代码规模等级很好;
- 大量有用的函数;
- 有可爱的亮点地方,当然;
MRV:(很少用到)——可以用-OpenMaya-Maya Python API 2.0
MRV is a python framework based on wrapping the Maya API to speed up development and ease of use within pipelines using Autodesk Maya.
MRV是一个基于包装Maya API的python框架,可以使用Autodesk Maya加快管道内的开发和易用性。
- 对C ++ API的python风格化“Pythonic”包装;
- 真正的 API格式化语法;
- 适合想要更快原型的程序员;
API:
- 使用C ++语言优化Maya;
- 创建自定义定位器locator,变形器deformers,节点nodes等;
- 不适用于脚本程序;
- 一些严重要的事情上;
每种语言都存在性能问题,但根据我的经验,一般情况下速度是一个不必在乎的问题,只是在某些情况下(通过大量的verting或者poly等来迭代)比较在乎。
更重要的事情是,如果你想的话,可以同时在同一个脚本中将所有这些语言放一起使用。一个python脚本可以导入maya.cmds和PyMEL(尽管会存在一点他们彼此重写覆盖的风险,所以,如果你真的想同时导入使用这两个模块脚本,你就必须导入到单独的命名空间里加以区分),PyMEL有一个mel命令调用特殊的mel case通过python访问大部分的API; 如果需要,您也可以导入MRV。
对于菜鸟(noobs),我会建议直接使用maya.cmds,然后根据需要,随着您的知识扩展而做出其他选择。