it's based on a clever prototype that Dean Edmonds posted on this site
awhile back. it works like this:
- using the API, create a garbage node with an integer attribute,
lock it and set it not to save with the scene.
- add an API callback to the node, so that when the special attribute
is changed, we get a callback
- the API queue is a list of simple python classes with undoIt and
redoIt methods. each time we add a new one to the queue, we increment
the garbage node's integer attribute using maya.cmds.
- when maya's undo or redo is called, it triggers the undoing or
redoing of the garbage node's attribute change (bc we changed it using
MEL/maya.cmds), which in turn triggers our API callback. the callback
runs the undoIt or redoIt method of the class at the index taken from
the numeric attribute.
pretty ingenious. much thanks to Dean for that one.
so, the API provides many methods which are pairs -- one sets a value
while the other one gets the value. the naming convention of these
methods follows a fairly consistent pattern. so what I did was
determine all the get and set pairs, which I can use to automatically
register api undo items: prior to setting something, we first *get*
it's existing value, which we can later use to reset when undo is
triggered.
so, this API undo is only for PyMEL methods which are derived from API
methods. it's not meant to be used with plugins. and since it just
piggybacks maya's MEL undo system, it won't get cross-mojonated.
-chad
On Mar 10, 2009, at 12:18 PM, Sebastian Thiel wrote:
> Could you briefly explain how the PyMel API Undo is working and what
> it is based on ?
> How do you separate attribute changes made by MEL ( and thus queued
> by MEL as well ), made by a plugin or made by a PyMel function ? How
> can a callback based system integrate into maya's existing undo
> queue ( without tracking things multiple times ) ?
>
> Thanks for a quick reply,
> Sebastian
>
> >
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---