mottosso / cmdc Goto Github PK
View Code? Open in Web Editor NEWMaya Python API 3.0
License: MIT License
Maya Python API 3.0
License: MIT License
I started using type annotations quite a lot these past months and I've grown to love them.
Since none of the Maya APIs are type annotated, every function takes and returns Any
. This is really frustrating to work with as you need to explicitly specify the type of a lot of variables when that should be inferred.
I think it would be really nice if cmdc was fully type annotated and made that one of its primary goals.
I haven't looked into how to set that up much so I'm not sure if pybind supports this or if we'd need to also write .pyi
stubs for that.
Hello, welcome to cmdc where we attempt to reproduce Maya Python API 2.0 (i.e. maya.api.OpenMaya
) in open source form, fix all bugs and add all of the things missing from it. Autodesk has shown little to no interest in continuing with API 2.0, and I was surprised to find nobody had yet taken matters into their own hands.
So let's do that!
I've put together a few source files demonstrating the fundamentals of how to bind the API, along with commonly used types like MVector
and MMatrix
and a function set, MFnDependencyNode
for manipulating the scene graph.
Here's the simplest example.
The syntax is a little cryptic, because it's doing a lot of automatic detection of argument types and return values. Things we'd otherwise have to do ourselves if manually binding via e.g. Python.h
. But it's fairly consistent and only consists of a few key functions, most if not all of them are already present in this repository.
But I need help. There is too much of an API to wrap for one person, and the task of actually binding a new C++ member is of intern-level complexity. That is, anyone can do it. The hard part is patience and diligence. We need to match function signatures, convert all MStatus
es to exceptions and write tests for each newly added member.
As soon as I spot some interest in the project, and interest in helping out, I'll expand upon the test suite and CI mechanism to automatically produce compiled versions for all platforms and versions of Maya, along with automatic upload to PyPI. From there, anyone can add or improve upon any member and we'll never have to struggle with maya.api.OpenMaya
again.
Glad you asked!
MYourMember.inl
filemain.cpp
Remember to keep the name of arguments as documented, so users of cmdc
can refer to this documentation for help on how to use cmdc
. And ditch the M
prefix that all classes have, Python don't need that.
MVector -> Vector
Any questions or concerns, post here or in a new issue and let's fix this thing once and for all!
Building a C-extension like cmdc with setup.py takes ~5 seconds.
That's insane. And we haven't even gotten started! The vast vast majority of that time is satisfying the pyproject.toml
file which dynamically installs a bunch of other Python packages it thinks we need to compile a dynamic library.
Instead, let's just make a plain-old-bash script for Linux and extend the current ps1
script for Windows. Worst case, we could employ CMake and have it spit out a Ninja build; that's been my goto for fast iteration times.
Hey Mac users, the stage has been set.
All that's needed is for someone to port the linux build script to Mac, and fill in the blanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.