Skip to main content

Set of extensions for Autodesk Maya's Python API

Project description

PyPI latest version Documentation status License

Bana is a set of extensions for Autodesk Maya’s Python API.

The Maya’s Python API is often a good choice over the commands layer whenever performances and robustness are valued. But because of its overall poor design, it is not uncommon that some fundamental functionalities are lacking out of the box and/or require too much boilerplate to get rolling.

Other gotchas to be expected include methods that became too daunting to use after porting in the worst possible way the API from C++ to Python, undocumented behaviours of certain features where error trialing is everything that is left, and methods throwing an exception when returning None would have been more appropriate.

Bana aims at reducing these shortcomings to provide a more friendly, predictable, and efficient developing environment.

Using the monkey patching package gorilla, new methods prefixed with bn are inserted within some classes from the maya.OpenMaya* modules, thus extending their functionalities while making these new methods feel as if they were built-in into Maya.

Since performances are a primary reason for using the API, a set of benchmarks built with the help of the package revl helps to ensure that these extensions remain as fast as possible.

Notes

Bana extends on Maya’s Python API 1.0 rather than 2.0 because the latter version seems to be still incomplete. That being said, it is encouraged to use the API 2.0 whenever possible since it provides a much more Pythonic interface with increased performances.

Bana does not aim at making the API more Pythonic. This could in some cases impact the performances, which goes against Bana’s goal of keeping things fast.

Features

  • easy retrieval of nodes from the scene.

  • robust and predictable specification for pattern matching with wildcards.

  • abstract away the usage of the maya.OpenMaya.MScriptUtil class.

  • performances as a top priority.

Usage

>>> import bana
>>> bana.initialize()
>>> from maya import OpenMaya
>>> # Retrieve a transform node named 'root'.
>>> root = OpenMaya.MFnTransform.bnGet(pattern='*|root')
>>> # Recursively iterate over all the DAG nodes child of 'root'.
>>> for node in root.bnFindChildren():
...     print(node)
>>> # Find all the mesh nodes in the scene containing the word 'Shape' but
... # not belonging to any namespace.
>>> for node in OpenMaya.MFnMesh.bnFind(pattern='*|*Shape*'):
...     print(node)

See the Tutorial section from the documentation for more detailed examples and explanations on how to use Bana.

Documentation

Read the documentation online at bana.readthedocs.io or check its source in the doc directory.

Author

Christopher Crouzet <christophercrouzet.com>

Thanks

  • Justin Israel for discovering that multiple instances pointing to a same Maya object return different hash values.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bana-0.1.0.tar.gz (77.6 kB view details)

Uploaded Source

Built Distribution

bana-0.1.0-py2.py3-none-any.whl (25.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file bana-0.1.0.tar.gz.

File metadata

  • Download URL: bana-0.1.0.tar.gz
  • Upload date:
  • Size: 77.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bana-0.1.0.tar.gz
Algorithm Hash digest
SHA256 42c86a018508049f1a8e19714fb79fb110420894c430117704f7d19a74a8b492
MD5 96f86e19be3a1e9dec921d7792417054
BLAKE2b-256 029af5cb46f538071d18fd57e1d52c7066344bb269e694e3d156cdea0e42d658

See more details on using hashes here.

File details

Details for the file bana-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for bana-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b3acd231d7bb0cbe4f2c5888f6f22396fff53767a12f5e494310127e9e52f6a1
MD5 73307e42730a481ce524c98c44199e7e
BLAKE2b-256 7e6127102cdbb28f71beded3afa07f2619ea5be1c6803655b714016059ab2139

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page