View Full Version : registerRedrawViewsCallback
05-21-2008, 09:43 AM
Is there any way of seeing what registerRedrawViewsCallbacks are running? or just to check if my callback is active?
05-21-2008, 05:38 PM
nobody? hmmm, my problem is that I'm trying make sure I unregister the callback when a rollout closes or on certain other conditions like an error (using try and catch) on on user demand. However it seems I'm inadvertently registering my callback more than once as I can't tell if Its already been registered, and then it seems impossible to unregister?
I'm a bit confused....
05-21-2008, 07:30 PM
like the time change callback, I don't think there's any way to...
- find out if your particular callback is already registered
- find out what callbacks, if any, are registered
- unregister a callback for which you no longer have access to the function; I.e. you declare the function somewhere, you register the callback, that 'somewhere' is lost and you then try to remove it.. you can't. And seeing as it survives through -everything- except an error in its own code, you have to restart max. Brilliant!
So... short of coding things safely so that you do not register it more than once (finding out why it appears to be doing so is always a good idea), here's a few things you can do...
1. Next to, or inside, the register function set a (global) variable that tells you that your callback is active.
2. Next to the unregister function, set a (global) variable that tells you that your callback is no longer active.
3. Declare the function used by the callback as global. That way, even if something goes wrong, you can at least unregister it again without having to restart max.
4. Consider a failsafe inside the function. E.g. make it divide by zero or so if a given variable is true. If 1-3 give no solution, then this will; by the very nature of viewport redraw / time change callbacks getting removed when the function called has an error.
05-22-2008, 09:58 AM
Thanks Richard this helps a lot, shame there seems to be no simple solution. I notice there was a new node event system (NodeEventCallback) introduced in 2008, which actually is more suited for what I'm doing... but then It seems even though it's in the help it's not actually implemented, so more pulling out of hair... argh
05-22-2008, 10:37 AM
What were you trying to do with the nodeEventCallback?
05-22-2008, 11:17 AM
I'm basically monitoring some changes to a mesh, so was using the redraw call back to kind of brute force it, but nodeEventCallback sounds exactly like what I want. However the examples in the help file don't work, and then I read on this forum that it missed the 2008 release even though it was still listed in the help (by bobo)
05-22-2008, 11:47 AM
ah, gotcha... yeah, when it's just plain not available to you - not much help there :)
The when/change handler bits are of no help?
05-22-2008, 01:34 PM
ahhh... I didn't know about change handlers, they look like they could do the trick, thanks, I'll check them out.
05-22-2008, 03:23 PM
Hmmm, it seems to be one step forward 2 steps back at the moemnt. Change handlers are great, but seem limited again. My function is too heavy to call in realtime as geomtry is adjusted, so I'm need to catch when user makes a change like moving some verts then releases the mouse button. Using the 'handle at' parameter you can wait for a time change or view update before you call the expression... but the view update is triggered every time when moving verts though, I guess cos the geomtry is redrawn.
I tried checking mouse button states, but they seem to return crazy results from within callbacks no?
05-22-2008, 03:23 PM
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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.