Detecting whether change handlers is triggered by undo/redo

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  02 February 2009
Question Detecting whether change handlers is triggered by undo/redo

Hello everybody!

I'm using a "when geometry myNode changes" construct to detect when the user moves vertices.
However, the change handler also gets called when doing undo/redo.
Is there a way to avoid this?

Thanks a lot!

Last edited by harefort : 02 February 2009 at 09:43 AM.
 
  02 February 2009
Hmm... the only thing I can think of is performing your code in a delayed fashion.
I.e. in your when handler, start a small timer that triggers after - I dunno - 100ms. IF within those 100ms the #sceneUndo / #sceneRedo system callback is triggered, stop your code from doing anything, otherwise carry on.

Sounds iffy, I know, but looks like there's no 'sceneUndoBegin' that triggers -before- the change and 'sceneUndoEnd' afterwards that would make what you'd need easypeasy.
 
  02 February 2009
Unhappy

Thanks for the reply!

I tried what you suggested, but it didn't work:

    local iTime1 = timeStamp()
    local iTime2 = timeStamp()
    while iTime2-iTime1 < 100 do
     (
    iTime2 = timeStamp()
    )
      


I also tried using sleep() with the same result:

Even with this delay the sceneUndo callback script is executed after the change handler.
So I'm afraid this is not possible.

Last edited by harefort : 02 February 2009 at 09:57 AM.
 
  02 February 2009
ouch.. wrong type of timer

That code will essentially halt all 3ds Max operations until your loop is done; a synchronous timer. You'll want an asynchronous timer - use either a rollout with a timer control in it, or create a .NET timer (see topic 'How To Call a MAXScript Function Periodically using DotNet' in help file).

No guarantee that -that- will work flawlessly, though.. like I said, it's pretty iffy.. say an undo takes 200ms to complete and the timer triggers and injects itself in the middle of that undo.. I'm hoping that doesn't happen and max queues the command until after the undo is finished.
 
  02 February 2009
Talking

Oh, I didn't know about those. Thanks!

However, as you said this solution is 'iffy', especially because it would delay any normal operation aswell.
So I chose another dirty solution: the change handler only executes when keyboard.controlpressed is false. :P
It's so dirty that I don't want my mom to know about it, but it's fast and works for most people, hopefully.
 
  02 February 2009
sounds like a relatively clean solution to me - didn't know you could still operate the meshes with control pressed
 
  02 February 2009
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 09:40 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.