I think you need to have the call to MGlobal.isUndoing within an API callback - ie, MEventMessage.addEventCallback("SelectionChanged", undoCallback, False) - instead of being made from a scriptJob.
- Paul On Sun, Mar 22, 2009 at 9:22 PM, Brandon & Kayla Harris <swooshi...@gmail.com> wrote: > I would like to find out how you actually implemented that piece of Maya API > to your scriptJob. I had actually run into the same problem, but my > scriptJob is based off of selection. When I try to use that API, I always > returns a false. I am assuming because by the time that it has run, the > object has already been selected and thus it's not in the middle of an > Undo. > How you finally built your work around would be nice. > thanks! > Brandon L .Harris > > On Sat, Mar 21, 2009 at 8:35 PM, Paul Molodowitch <elron...@gmail.com> > wrote: >> >> Oops... forgot to add that code to play with: >> >> http://pastebin.com/m177e22bc >> >> Execute it, then change the value of .translateX, and undo / redo >> to see when various callbacks are triggered >> >> - Paul >> >> >> On Sat, Mar 21, 2009 at 5:32 PM, barnabas79 <elron...@gmail.com> wrote: >> > >> > Hi all - so, I'm wondering if there's a way to detect when changes to >> > an attribute are caused by an undo / redo. >> > >> > Ie, I have a script that that, whenever a certain attribute is >> > changed, automatically makes some other changes to the scene as well. >> > In other words, the flow looks like: >> > >> > state1 --(attrChange)--> state2 -->(scriptTriggered) ---> >> > (scriptChanges) ---> state3 >> > >> > (Note - I've tried having the script triggered by >> > MNodeMessage.addAttributeChangedCallback and a scriptJob >> > (attributeChange=[...]), and have the same problem with both...) >> > >> > Everything is working fine and dandy... until I tried to get things >> > working with undo. The problem here is that, if I change my target >> > attribute (which triggers my script), then later undo the change to >> > the target attribute, this registers as another attribute change, >> > which triggers my script again. >> > >> > The obvious solution would be to add an undo callback which would >> > temporarily disable my script, then re-enable when the undo was >> > finished (for instance, when maya is idle) - the problem is that the >> > undo callback is triggered AFTER the attribute changed callback. >> > >> > Is there any way to have my script know that it's actually been >> > triggered by an undo? >> > >> > - Paul >> > >> > PS - Here's some code that will give feedback on when attribute >> > change / undo / redo callbacks are triggered, that will allow you to >> > see for yourself that A) an undo triggers and attribute change >> > callback, and B) the undo callback is triggered AFTER this attribute >> > change callback >> > > >> > >> >> > > > > > --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/python_inside_maya -~----------~----~----~----~------~----~------~--~---