All Projects → mottosso → cmdc

mottosso / cmdc

Licence: MIT license
Maya Python API 3.0

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to cmdc

skinner
Skin export / import tools for Autodesk Maya
Stars: ✭ 68 (-30.61%)
Mutual labels:  pipeline, maya, rigging
gt-tools
GT Tools is a free collection of scripts for Autodesk Maya
Stars: ✭ 44 (-55.1%)
Mutual labels:  maya, autodesk, rigging
polyReorder
Maya plugin with tools to reorder the vertices on a mesh to match the order of another.
Stars: ✭ 21 (-78.57%)
Mutual labels:  maya, rigging
node calculator
Create Maya node-network by entering a math-formula.
Stars: ✭ 56 (-42.86%)
Mutual labels:  maya, autodesk
polySymmetry
Maya tool for finding the symmetry of a polygon mesh based on the topology.
Stars: ✭ 51 (-47.96%)
Mutual labels:  maya, rigging
onionSkinRenderer
This is an Onion Skin Renderer for Autodesk Maya
Stars: ✭ 93 (-5.1%)
Mutual labels:  maya, autodesk
MayaToolbox
Comprehensive intro to Maya Python.
Stars: ✭ 16 (-83.67%)
Mutual labels:  maya, rigging
Mayanomicon
Custom nodes and introspection with the maya API
Stars: ✭ 28 (-71.43%)
Mutual labels:  maya, rigging
revl
Helps to benchmark code for Autodesk Maya.
Stars: ✭ 14 (-85.71%)
Mutual labels:  maya, autodesk
bookmarks
A PySide2 based file and asset manager for animation and CG productions.
Stars: ✭ 33 (-66.33%)
Mutual labels:  pipeline, maya
TACTIC-Handler
PySide based TACTIC client for maya, nuke, 3dsmax, houdini, etc
Stars: ✭ 67 (-31.63%)
Mutual labels:  pipeline, maya
AnimationDNA
Maya > Arnold > Nuke pipeline
Stars: ✭ 101 (+3.06%)
Mutual labels:  pipeline, maya
xformArrayNodes
Maya plugin with nodes designed to operate on transform components.
Stars: ✭ 27 (-72.45%)
Mutual labels:  maya, rigging
bana
Set of extensions for Autodesk Maya's Python API.
Stars: ✭ 32 (-67.35%)
Mutual labels:  maya, autodesk
Al usdmaya
This repo is no longer updated. Please see https://github.com/Autodesk/maya-usd
Stars: ✭ 253 (+158.16%)
Mutual labels:  pipeline, maya
weights editor
A Maya tool to edit skin weights
Stars: ✭ 52 (-46.94%)
Mutual labels:  maya, rigging
maya cpp reference docset
Dash-compatible docset for the Maya C++ API reference.
Stars: ✭ 19 (-80.61%)
Mutual labels:  maya
artifact-promotion-plugin
A simple Jenkins plugin to promote artifacts.
Stars: ✭ 29 (-70.41%)
Mutual labels:  pipeline
pipeline-as-yaml-plugin
Jenkins Pipeline As Yaml Plugin
Stars: ✭ 111 (+13.27%)
Mutual labels:  pipeline
cherry-on-py
Cloud computing is a game changer for developers. What can you do in a couple hundred lines of code?
Stars: ✭ 67 (-31.63%)
Mutual labels:  pipeline

a.k.a. "Maya Python API 3.0"


An alternative set of bindings for the C++ API of Maya 2018-2023.

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?
  • What if setting up code completion and type checking was easy?

That's what this repository is for.


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.

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")

Code completion working in Visual Studio Code with Pylance

Type Checking working in Visual Studio Code with Pylance


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

  • cmdc comes with fully type annotated stubs, making it easy to set up code completion as well as type checking.

Status

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.


Repository

File Description
cmake/ CMake setup for Maya and Python libraries
docker/ Docker containers for building in linux
os/ The missing Python libraries for all operating systems and Python versions
pyblind11/ The pybind11 source
scripts/ Code-generation
src/ C++ source for the pybind11 bindings
tests/ Tests for bound methods and types

Build

Build requirements:

cmake -B ./build -DCMAKE_BUILD_TYPE=Release -DMAYA_VERSION=2020 -DMAYA_DEVKIT_ROOT="path/to/devkit"
cmake --build ./build --config Release

This should build on any platform, for any Maya with Python available. Including 2023.


Contributing

Interested in helping out? Here's how to do it.

  1. Get a free compiler, like Visual Studio 2019 for Windows
  2. Download and unzip a Maya devkit (scroll down)
  3. Clone this repository
  4. Write your header file
  5. Submit a pull-request
  6. Profit

FAQ

Do I need to know C++?

Not really! What we're doing here is mostly busy-work, filling in the many functions exposed by the Maya API. Most if not all trickery has already been done in other functions, so copy/paste is a valid option.

I don't have any other questions?

Great, then here's what's next.

# Tell cmdc about where your devkit is
$env:DEVKIT_LOCATION="C:\maya-devkit"

# Clone the big jeeves out of this repository
git clone https://github.com/mottosso/cmdc.git

cd cmdc

# Either write your own header from scratch..
# ..or generate some boiler plate of your favourite header!
mayapy ./scripts/parse_header.py MFnDagNode.h

From here, you'll have a freshly generated header file, ready to fill in. As you fill things in, see build above for how to iterate and once you're happy you're welcome to submit a Pull Request!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].