Metadata-Version: 2.4
Name: mayatk
Version: 0.36.4
Summary: Python toolkit for Autodesk Maya: modeling, UV, materials, animation, rigging, lighting and scene-export utilities.
Author-email: Ryan Simpson <m3trik@outlook.com>
License-Expression: LicenseRef-MIT-Commons-Clause
Project-URL: Homepage, https://github.com/m3trik/mayatk
Project-URL: Repository, https://github.com/m3trik/mayatk
Project-URL: Changelog, https://github.com/m3trik/mayatk/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/m3trik/mayatk/issues
Keywords: m3trik,maya,autodesk-maya,maya-python,rigging,animation-tools,technical-art,dcc
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Intended Audience :: Developers
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pythontk>=0.27.3
Requires-Dist: uitk>=1.13.2
Dynamic: license-file

[![License: MIT + Commons Clause](https://img.shields.io/badge/License-MIT%20%2B%20Commons%20Clause-blue.svg)](https://github.com/m3trik/mayatk/blob/main/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/mayatk.svg)](https://pypi.org/project/mayatk/)
[![Python](https://img.shields.io/badge/Python-3.11+-blue.svg)](https://www.python.org/downloads/)
[![Maya](https://img.shields.io/badge/Maya-2025+-orange.svg)](https://www.autodesk.com/products/maya/)
[![Tests](https://img.shields.io/badge/Tests-9331%20passed-brightgreen.svg)](../tests/)
![Platform](https://img.shields.io/badge/Platform-Windows%2C%20Linux-lightgrey.svg)

# mayatk

**Composable primitives for Maya, and the tools built from them.** mayatk is the Maya library behind the [tentacle](https://github.com/m3trik/tentacle) toolset, built on `maya.cmds` and OpenMaya 2.0, with no PyMEL.

<!-- diagram:ecosystem/mayatk -->
<!-- Generated by m3trik/scripts/generate_readme_diagrams.py from the workspace's declarations: change those and re-run it, never this block. -->
<p align="center">
<a href="https://github.com/m3trik/m3trik#readme"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/m3trik/m3trik/main/docs/diagrams/ecosystem-mayatk-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/m3trik/m3trik/main/docs/diagrams/ecosystem-mayatk-light.svg"><img alt="mayatk (highlighted) in the ecosystem: uitk requires pythontk; unitytk requires pythontk; mayatk requires uitk; blendertk requires uitk; tentacle requires uitk; extapps requires uitk; tentacle installs mayatk as its [maya] extra; tentacle installs blendertk as its [blender] extra; tentacle opens extapps by name (its [apps] extra) and never imports it; mayatk and blendertk share a mirrored API. tentacle and extapps are products, which nothing imports." src="https://raw.githubusercontent.com/m3trik/m3trik/main/docs/diagrams/ecosystem-mayatk-light.svg" width="781"></picture></a>
</p>
<!-- /diagram:ecosystem/mayatk -->

## Design

| Principle | In practice |
|:--|:--|
| **Primitives that combine** | Small classes such as `NodeUtils`, `Attributes` and `XformUtils` take node names and return plain values, with no wrapper objects, so they mix freely with your own `maya.cmds` code. A compound operation is still one undo step. |
| **Logic without UI** | Every tool is a plain Python class with no UI; its panel only calls it. A script, a test or an AI agent runs exactly what an artist runs, on the selection by default or on the objects it is given. |
| **One API, two hosts** | [blendertk](https://github.com/m3trik/blendertk) mirrors each operation by name, and shared logic is written once in [pythontk](https://github.com/m3trik/pythontk) behind an adapter. One panel serves Maya and Blender; CI fails when it calls what one library lacks. |
| **Self-describing exports** | Shots, audio cues, lightmaps and materials travel inside the exported file, where Unity and the WebXR viewer read them through types generated from one declaration. A shot arrives in Unity as a named animation clip, and a lightmap binds to its object with no setup. |
| **Non-destructive** | The exporter stages what it changes for the file and puts it back, however the run ends. Smart Bake and Texture Combine record what they change inside the scene itself, so either is reversed exactly after the scene is saved, closed and reopened. |
| **Exact undo** | Edits made through OpenMaya normally bypass Maya's undo queue; `UndoRecorder` routes them through a command that ships with Maya, so a fast API edit undoes as one ordinary step. A live preview stays out of the undo history until it is committed, then counts as a single step. |
| **Faster, and proven equal** | Smart Bake samples the timeline in a single OpenMaya pass in place of Maya's `bakeResults`. A test requires the same keys from both; on a production scene they matched across 1.2 million keys, in 4.8 s instead of 144.8 s. |
| **Test-driven, inside Maya** | Every bug is reproduced as a failing test before it is fixed, and the test stays in the suite. More than 9,000 tests run inside Maya itself, and a release requires a full passing run recorded against that exact source. |

Public names are a contract: one that moves raises an error naming its new home. The reasoning behind each rule is in the [code standard](https://github.com/m3trik/m3trik/blob/main/docs/CODE_STANDARD.md).

## What's in it

Every class is available from the package root (`mtk.NodeUtils`) and loads on first use. A linked name opens that tool's readme.

| Package | What it holds |
|:--|:--|
| `anim_utils` | Animation curves and keys, [Shot Manifest](shot_manifest.md), [Shot Sequencer](shot_sequencer.md), Smart Bake, key stash, blendshape animation, playblast |
| `audio_utils` | Audio clips, ffmpeg-backed conversion, timeline-keyed events |
| `cam_utils` | View capture and framing, camera clipping, cameras from the current view, view state save and restore |
| `core_utils` | `CoreUtils`, `Components`, `UndoRecorder`, `Preview`, `AutoInstancer`, the scene audit and repair helpers, MASH bridge |
| `display_utils` | Visibility and isolation, color ID, exploded view |
| `edit_utils` | `Selection`, naming, primitives, snap, bevel, bridge, mirror, duplicate (linear, radial, grid), mesh graph |
| `env_utils` | `MayaConnection`, workspaces, namespace sandbox, references, hierarchy sync, FBX and USD, [Scene Exporter](scene_exporter.md), Blender and Unity bridges, WebXR preview |
| `light_utils` | [Lightmap Baker](lightmap_baker.md), [Light Rigs](light_rig.md), HDR manager, lights from geometry |
| `mat_utils` | `GameShader`, `RenderEffects`, `ImageToPlane`, `MatUpdater`, shader templates, [Emissive Groups](emissive_groups.md), Marmoset and Substance bridges |
| `node_utils` | `NodeUtils`, `Attributes`, the Channels engine, [scene data nodes](data_nodes.md) |
| `nurbs_utils` | NURBS surfaces, `ImageTracer`, curve to tube |
| `render_utils` | Renderer switching, render settings and their presets |
| `rig_utils` | `Controls`, skinning, tube, wheel and telescope rigs, [Articulated Rig](articulated_rig.md), [Shadow Rig](https://github.com/m3trik/tentacle/blob/main/docs/tools/shadow_rig.md) and its [design note](shadow_rig_morphing.md) |
| `ui_utils` | `MayaUiHandler`, the marking-menu host adapter, channel box, native menus, hotkey collision check, node icons |
| `uv_utils` | Unwrap, pack and transfer UVs, [Texture Combine](texture_combine.md), Rizom bridge |
| `xform_utils` | Freeze and restore transforms, pivots, alignment and placement, matrices |

To find any public name, search the installed source: `python -m pythontk ops run api.search "query=<words>"`. Over MCP, an agent gets the same search and runs its calls in a Maya started for it ([setup](https://github.com/m3trik/m3trik/blob/main/docs/AGENT_INSTRUCTIONS.md#elsewhere)). See also: [changelog](../CHANGELOG.md) · [tests](../tests/README.md) · [contributing](../AGENTS.md) · [issues](https://github.com/m3trik/mayatk/issues).

## Install

```bash
pip install mayatk
```

[tentacle's installer](https://github.com/m3trik/tentacle#install) installs it together with the panels.

```python
import mayatk as mtk

@mtk.CoreUtils.undoable                           # the whole call is one undo step
def freeze_groups(nodes):
    groups = mtk.NodeUtils.is_group(nodes, filter=True)
    with mtk.CoreUtils.preserved_selection():     # restores the selection afterwards
        mtk.XformUtils.freeze_transforms(groups)
    return groups

groups = freeze_groups(["grp_a", "grp_b", "pCube1"])
mtk.XformUtils.restore_transforms(groups)         # restores the values it zeroed
```

## License

MIT with the [Commons Clause](https://commonsclause.com/) — see [LICENSE](https://github.com/m3trik/mayatk/blob/main/LICENSE). Free to use, modify and share, including in paid production work; what it forbids is selling mayatk, or a product or service whose value comes mainly from it. The Blender-side scripts under `env_utils/blender_bridge/templates/` are plain MIT, since code that runs inside Blender must be GPL-compatible.
