Hello everyone,
Thanks for the madhack category — I’d like to contribute something that helped me a lot in working with the Maya API using Python.
When working with the Maya API in Python, it’s important to clearly distinguish between two spaces:
- The current state of the Maya scene
- Python’s in-memory space, where class instances, caches, and local data live
These two memory spaces exist independently and are not automatically synchronized.
Typical example:
# Querying actual scene connections
geoNode.getConnections()
# Accessing cached data from memory
geoNode.attr1
Important notes:
- Undo/Redo only affects the scene state
- Crashing Maya or opening files from outsourcing teams clears Python memory completely
To avoid confusion, I use a simple mnemonic rule based on function naming:
read_* → works with Python in-memory data only
get_* → pulls fresh data from the Maya scene
Mental model:
- Python memory = a book (static, structured, local)
- Maya scene = a physical space (dynamic, evaluated, external)
This small naming convention helped me a lot when designing tools, especially to avoid bugs caused by stale or desynced data.
Maybe this seems obvious now, and it might not qualify as a full-on “madhack”,
but back then it really clarified things for me.
Hope it helps someone out there.