MDagModifier outside of a plugin

So, I’ve got a situation that really doesn’t demand a full on python plugin – i’m just assembling a mesh in Script. Works fine, many X faster than doing it with straight cmds.

However…

Because the creation does not happen inside an MPXCommand derived plugin, undo does not work correctly. I can bracket the creation with an MDagModifier, and that allows for undo/redo:



mod = openMaya.MDagModifier()

## do stuff
mod.doIt() # register the action

If I keep a reference to ‘mod’, I can undo the action with mod.undoIt(). However it’s not part of the undo queue – it’s an action I invoke with the doIt() / undoIt() methods on the mod object. Most MPXcommands I’ve seen keep a modifier in their state to handle this – but since I don’t really need anything except the scripted functionality here, I’d really rather avoid the hassle of making a whole plugin just for this one function.

I’m thinking I could gin up a proxy callable that did go into the undo queue – but I can’t think of anything that hooks to stuff in the queue and tells it ‘i’m undoing you’ …

Has anybody fiddled with this? Or do I just have to bit the API bullet and write it as a dang plugin ?