<a href=/cmda/><p align=center><img width=90 src=https://user-images.githubusercontent.com/2152766/113510233-ca120400-9551-11eb-9a34-b8846a2c959c.png></p></a>
<p align=center>a.k.a. "Maya Python API 3.0"</p>
<br>
Another set of bindings for the C++ API of Maya 2018-2022.
**Why?**
- What if Maya's Python bindings were open source?
- What if whenever Maya crashed, you'd get more than an opaque stack trace?
- What if you were able to see why a crash occurred, and what line it occurred on?
- What if you could address bugs in the bindings yourself?
- What if you could *add* missing members yourself?
- What if there were bindings for Maya that made it impossible to crash Maya from Python?
That's what this repository is for.
<br>
### Example
The bindings should aim to match Maya Python API 2.0 as closely as possible, with the exception of being open source and to *never* allow Maya to crash as a result of calling any function or method.
```py
import cmdc
typ = cmdc.TypeId(16)
mat4 = cmdc.Matrix()
mat4 *= cmdc.Matrix().inverse()
vec3 = cmdc.Vector()
vec3.x = 6
quat = cmdc.Quaternion(angle=0.5, axis=cmdc.Vector(1, 0, 0))
mat4 *= quat
# No need for MString
string = str()
# Modify the Maya scene graph
from maya import standalone
standalone.initialize()
fn = cmdc.FnDependencyNode()
r = fn.create("reverse", name="myReverse")
print(fn.name())
# This next line really shouldn't work, should require MFnDagNode
t = fn.create("transform", name="myTransform")
print(fn.name())
print("Success")
```
<br>
### Goal
`cmdc` should have the same advantages over 1.0 as 2.0, and more.
- Array types are full Python sequences, including slice support.
- Methods which take Maya array parameters will *always* also take native Python sequences, such as arrays and tuples.
- The outputs of methods are *always* returned in their return values, not through their parameter lists.
- Methods which return multiple values (e.g. MFnFluid.getResolution) return them as a tuple or list, eliminating the need for MScriptUtil.
- Object attributes are preferred over rather than set/get methods. For example you can now write array.sizeIncrement=64.
- There are more types of exceptions used when methods fail. Not everything is a RuntimeError, as was the case in the old API.
- `cmdc` should be faster or as fast as API 2.0
> [Reference](https://help.autodesk.com/view/MAYAUL/2020/ENU/?guid=__py_ref_index_html)
<br>
### Status
![](https://img.shields.io/badge/prototype-0.1-brightgreen)
It'll work, but won't have half the things you'll need to do anything of use in Maya. The current source is enough to illustrate (1) how to expose types, (2) how to expose function sets and (3) how to deal with passing MObject references around.
**How can I help?**
It's easy but tedious.
- Add more members
- Add more tests
<br>
### Repository
| File | Description
|:-----|:-------------
| `src/` | C++ source for the pybind11 bindings
| `install/` | Destination of the compiled binding, e.g. `cmdc.pyd`
| `build.ps1` | Example build script for Maya 2020 on Windows
| `pyproject.toml` | `setup.py` uses this ahead of building
| `setup.py` | Let pip handle actually compiling the extension
| `test.py` | Tests for bound methods and types
<br>
### Build
This should build on any platform, for any Maya with Python available. Including 2022. Included is an example build script for Maya 2020 on Windows.
- C++11 compatible compiler, e.g. Visual Studio 2015
- Maya 2020
- pip 19+
```pwsh
# Prerequisities the script cannot figure out on its own
$env:DEVKIT_LOCATION="C:\github\maya-devkit\2020.2\windows"
$env:MAYA_LOCATION="C:\Program Files\Autodesk\Maya2020"
# Go!
.\build.ps1
```
**How can I help?**
More easy but tedious things.
- Add more Maya versions
- Add more platforms
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
亦称“ Maya Python API 3.0” Maya 2018-2022的C ++ API的另一组绑定。 为什么? 如果Maya的Python绑定是开源的怎么办? 如果每当Maya崩溃时,您得到的不仅仅是透明的堆栈跟踪,该怎么办? 如果您能够了解崩溃的原因以及发生在哪一行,该怎么办? 如果您可以自己解决绑定中的错误该怎么办? 如果您可以自己添加缺少的成员该怎么办? 如果Maya的绑定使不可能使Maya从Python崩溃怎么办? 这就是该存储库的用途。 例子 绑定应旨在尽可能接近地匹配Maya Python API 2.0(开放源除外),并且决不允许由于调用任何函数或方法而导致Maya崩溃。 import cmdc typ = cmdc . TypeId ( 16 ) mat4 = cmdc . Matrix () mat4 *= cmdc . Matrix ().
资源详情
资源评论
资源推荐
收起资源包目录
cmdc-master.zip (13个子文件)
cmdc-master
setup.py 843B
.gitignore 18B
pyproject.toml 129B
src
MFnDependencyNode.inl 3KB
MPlug.inl 174B
Math.inl 4KB
Types.inl 1KB
main.cpp 998B
build.ps1 1KB
install
.gitignore 0B
LICENCE 1KB
README.md 4KB
test.py 555B
共 13 条
- 1
DeepIndaba
- 粉丝: 26
- 资源: 4658
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 对Hibernate框架的二次封装,简化对数据库的操作
- 5152单片机proteus仿真和源码用定时器T1查询方式控制单片机发出1KHz音频
- 由 Top10 开发和使用的惯用 Scala Redis 客户端 这是一项正在进行的工作,虽然在生产中使用,但应将其视为在生产中
- SwiftUI - SceanAppDelegate
- SwiftUI - AppDelegate
- Cetus是由C语言开发的关系型数据库MySQL的中间件,主要提供了一个全面的数据库访问代理功能
- 5152单片机proteus仿真和源码用定时器T0的中断实现渴望主题曲的播放
- 数据库垂直分区,业务逻辑层 配合数据库中间件实现水平分区和垂直分区
- 5152单片机proteus仿真和源码用定时器T0的中断控制1位LED闪烁
- 这是用于在 Akka 集群中复制数据的库的早期预览 它是一个复制的内存数据存储,支持低延迟和高可用性 要求
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0