Metadata-Version: 2.4
Name: blendertk
Version: 0.28.0
Summary: Python toolkit for Blender mirroring mayatk's API: modeling, UV, materials, animation, rigging and export utilities.
Author-email: Ryan Simpson <m3trik@outlook.com>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/m3trik/blendertk
Project-URL: Repository, https://github.com/m3trik/blendertk
Project-URL: Changelog, https://github.com/m3trik/blendertk/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/m3trik/blendertk/issues
Keywords: m3trik,blender,blender-python,bpy,rigging,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.10
Description-Content-Type: text/markdown
License-File: COPYING
License-File: COPYING.EXCEPTION
Requires-Dist: pythontk>=0.27.0
Requires-Dist: uitk>=1.12.1
Dynamic: license-file

[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)
[![PyPI](https://img.shields.io/pypi/v/blendertk.svg)](https://pypi.org/project/blendertk/)
[![Blender](https://img.shields.io/badge/Blender-4.x+-orange.svg)](https://www.blender.org/)
[![Tests](https://img.shields.io/badge/Tests-8103%20passed-brightgreen.svg)](../tests/)
![Platform](https://img.shields.io/badge/Platform-Windows%2C%20Linux-lightgrey.svg)

# blendertk

<!-- short_description_start -->
*Blender 4.x+ tech-art toolkit mirroring [mayatk](https://github.com/m3trik/mayatk)'s public API (`btk.X` ↔ `mtk.X`) — modeling, animation, materials, rigging, and scene-pipeline automation over native `bpy`/`bmesh`, plus one-click bridges into Marmoset, Substance Painter, RizomUV, Maya, Unity, and the browser. The tool panels over it are [tentacle](https://github.com/m3trik/tentacle)'s.*
<!-- short_description_end -->

blendertk is the Blender layer of the `pythontk → uitk → {mayatk, blendertk} → tentacle` ecosystem: the tools [mayatk](https://github.com/m3trik/mayatk) gives Maya, under the same names, so one [tentacle](https://github.com/m3trik/tentacle) panel serves both hosts.

<!-- diagram:ecosystem/blendertk -->
<!-- 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-blendertk-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/m3trik/m3trik/main/docs/diagrams/ecosystem-blendertk-light.svg"><img alt="blendertk (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-blendertk-light.svg" width="781"></picture></a>
</p>
<!-- /diagram:ecosystem/blendertk -->

## Install

```bash
pip install blendertk
```

Blender 4.x+ (developed against 5.1 / Python 3.13). `bpy` comes from Blender itself.

## The design, and what it buys

- **A mirror, by name and behavior.** Each operation has mayatk's name, and its signature too wherever a shared panel makes the call. A panel is therefore written once, with no branch for either host:

  ```python
  import blendertk as btk

  btk.EditUtils.mirror(...)                   # mtk.EditUtils.mirror in Maya
  btk.SmartBake().execute()                   # mtk.SmartBake().execute()
  btk.SmartBake.restore()                     # mtk.SmartBake.restore()
  ```

- **The mirror is measured, not trusted.** A script resolves every call tentacle's shared panels make against both libraries and lists each gap ([PARITY_SURFACE.md](https://github.com/m3trik/tentacle/blob/main/docs/PARITY_SURFACE.md)). A call one host lacks must be hidden in that host's panel, or the check fails in CI. What is still unported, and in what order it will be, is in [PARITY_AUDIT.md](https://github.com/m3trik/tentacle/blob/main/docs/PARITY_AUDIT.md) and [PARITY_PORTING_PLAN.md](https://github.com/m3trik/tentacle/blob/main/docs/PARITY_PORTING_PLAN.md).
- **Thin where Blender is already good.** Where Blender ships a capability, blendertk is a thin adapter over the `bpy` / `bmesh` operator. Where it does not, the logic is written once in [pythontk](https://github.com/m3trik/pythontk) and both host libraries bind it, so neither holds a second copy to drift.
- **Importing it never needs Blender.** Every `bpy` import is deferred into the call that uses it, so the whole API is searched, documented and unit-tested with no Blender running.

## Highlights

The tools themselves are described once, in [mayatk's README](https://github.com/m3trik/mayatk#the-tools): the shot tools, the Scene Exporter, Smart Bake, Texture Combine and the rigs do the same job here under the same names. What is particular to Blender:

- **A Maya scene opens in Blender, and a Blender scene in Maya.** `MayaSceneImport` converts a `.ma` / `.mb` through a headless Maya and imports the result, translating the shaders FBX cannot carry and rebuilding packed PBR maps. `MayaBridge.send()` goes the other way: it exports the selection and opens it in a Maya launched for it, and `save_as()` writes the `.ma` / `.mb` with no Maya window at all.
- **Lightmaps baked in Cycles, read by every exporter.** `LightmapBaker` bakes to a second UV set and records the result in the scene, where the FBX export to Unity, the GLB export and the [live WebXR preview](https://github.com/m3trik/pythontk/blob/main/docs/webxr_preview.md) each find it. A scene with no bake exports as it always did.
- **One project folder for both hosts.** Blender reads and writes Maya's `workspace.mel`, so a project set up in either host is set up in the other.
- **Hierarchy sync against a `.blend` or an `.fbx`.** The scene is compared with a reference file; missing objects are stubbed or pulled in, extras are set aside, and renames and reparents are repaired.
- **Drive Blender from outside.** `BlenderConnection` launches a background Blender of its own and runs code in it, as mayatk's `MayaConnection` does for Maya. The test suite runs this way, and an artist's open session is never touched.

<details>
<summary><b>Package map</b>: the same subpackages, modules and classes as mayatk</summary>

| Package | What it covers |
|---|---|
| `anim_utils` | Shots suite (the Blender host of the shared pythontk shots engine, and the manifest and sequencer hosts tentacle's panels call), smart bake, blendshape animation, playblast, key scaling/staggering |
| `audio_utils` | Sound-strip CRUD over the Video Sequence Editor (deliberately not a mirror of Maya's DG-node audio machinery) |
| `cam_utils` | Camera utilities |
| `core_utils` | `CoreUtils`, `AutoInstancer`, `Preview` (uitk's `PreviewController` bound to a Blender session), script-job manager over `bpy.app.handlers`, diagnostics |
| `display_utils` | Color ID, exploded view, Blender-only `OutlinerTint` |
| `edit_utils` | `EditUtils`, mirror, cut-on-axis, duplicate (linear/radial/grid), bevel, bridge, snap, naming, curtain rig, target weld |
| `env_utils` | `BlenderConnection`, the `blender` operation host (`BlenderSceneFiles`), workspaces (`workspace.mel` shared with Maya), reference manager, hierarchy sync, FBX/USD, scene exporter, Maya + Unity bridges, WebXR preview, docked script console |
| `light_utils` | Lightmap baker + web export, HDR manager, lights-from-geometry |
| `mat_utils` | Game shader, material updater, texture path editor, shader templates, render opacity, image-to-plane, emissive groups, Marmoset + Substance live-RPC bridges |
| `node_utils` | `NodeUtils`, `DataNodes` ([shared scene data carriers](data_nodes.md)), the Channels engine |
| `nurbs_utils` | Curve helpers (relaxed mirror), `ImageTracer`, curve-to-tube |
| `render_utils` | Render engines, render settings + presets, render cameras, a rendered frame (mayatk's names; no IPR) |
| `rig_utils` | Constraints/drivers/armature primitives; tube / wheel / telescope / shadow / [articulated](https://github.com/m3trik/mayatk/blob/main/docs/articulated_rig.md) rigs |
| `ui_utils` | `BlenderUiHandler`, the marking-menu host adapter (Qt running inside Blender, the activation key in Blender's own keymap), native-menu wrapper, Qt dock container, calculator, style setter |
| `uv_utils` | UV utilities, [Texture Combine](https://github.com/m3trik/mayatk/blob/main/docs/texture_combine.md) (material atlas combine + UV / texture transfer), Rizom bridge |
| `xform_utils` | Transforms and matrix IO |

What corresponds, and what is deliberately absent on each side and why: [`STRUCTURE.md`](STRUCTURE.md). The whole public surface, searched live from the installed source: `python -m pythontk ops run api.search "query=<words>"`.

</details>

## Guides

- **[Scene data nodes](data_nodes.md)** — the `data_internal` / `data_export` carriers and how their metadata rides into the FBX (Blender delta of [mayatk's owner doc](https://github.com/m3trik/mayatk/blob/main/docs/data_nodes.md))
- **[Shot Sequencer](https://github.com/m3trik/mayatk/blob/main/docs/shot_sequencer.md)** (mayatk, one guide for both hosts) — the per-shot animation timeline and its graph view; the panel's `?` help links here
- **[Emissive groups](https://github.com/m3trik/mayatk/blob/main/docs/emissive_groups.md)** (mayatk, cross-package reference) — regions whose glow plays on its own, as materials; blendertk's `EmissiveGroups` tags each copy on its node tree
- **[Live WebXR preview](https://github.com/m3trik/pythontk/blob/main/docs/webxr_preview.md)** (pythontk) — the shared DCC → glTF → headset pipeline behind `btk.WebXrPreview`

## Links

- **Full API:** `python -m pythontk ops run api.search "query=<words>"` (the installed source, searched)
- **Structure / parity map:** [`STRUCTURE.md`](STRUCTURE.md)
- **Test suite:** [`tests/README.md`](../tests/README.md) — suite layout, sentinel conventions, fresh-instance runner
- **Changelog:** [`CHANGELOG.md`](../CHANGELOG.md)
- **Contributor / AI-agent guide:** [`AGENTS.md`](../AGENTS.md)
- **PyPI:** https://pypi.org/project/blendertk/
- **Issues:** https://github.com/m3trik/blendertk/issues

## License

GPL-3.0-or-later — see [COPYING](https://github.com/m3trik/blendertk/blob/main/COPYING), plus an additional permission to combine it with mayatk, tentacle and Autodesk Maya ([COPYING.EXCEPTION](https://github.com/m3trik/blendertk/blob/main/COPYING.EXCEPTION)).
