Maya 2022 and api.OpenMaya.MDagModifier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
In narrowing down a troublesome crash I found a change in behavior of the MDagModifier from previous version of Maya.
from maya import cmds
from maya.api import OpenMaya as om
mod = om.MDagModifier()
mod.createNode("transform")
mod.createNode("transform")
mod.createNode("transform")
mod.doIt()
cmds.file(new=True, force=True)
mod.undoIt()
In Maya 2020 and below, this would instantly kill Maya. Which is "great" because what is the modifier to do? The nodes it's attempting to undo aren't there anymore, so it'd be accessing bad memory. One could argue that a better response would be to throw an exception, but at least it isn't doing what Maya 2022 is doing!
In Maya 2022, this deletes the *last* 3 DAG nodes in your scene, which is most often the side, front and top cameras.
I say last, because presumably there's some sort of indexing going on, and those three transforms that got created incremented that index. The first node is persp. If you try and create one more node, I'd expect persp to go as well, but that's when Maya calls it a day and crashes.
It's not the trouble I was looking for, but I'm close. 2022 is the only Maya that crashes currently, and I suspect MDagModifier and how it likes to hold onto node references, preventing custom nodes from calling their destructor until the Python `mod` variable goes out of scope or is deleted.