When / where to redraw?


Just a quick question: I’m looking for advice on when to trigger a redraw if using Pre and PostDraw methods in a display conduit class.

Should the redraw method be called at the end of each Pre and PostDraw method or just once from another place, for example at the end of RunCommand?

I don’t think you should call redraw at all, it will call you!
That is, you should not call redraw inside a display conduit. At the end of a command is no problem.

If your conduit is showing animated properties you may have to start redrawing the viewports more often than Rhino does. Grasshopper for example needs to redraw whenever it has updated it’s data, and there’s no command or viewport navigation event that would do this automatically.

I’m not 100% sure but you can call Redraw whenever you want. It will not cause an immediate redraw but instead will result in a redraw some time in the near future, when other code has finished doing whatever it’s doing.


A sincere thanks.

btw: stepping into Rhino development thanks to Grasshopper’s success - looking at my first attempt at translating work across!


Appreciate the speedy reply - I will try to find the strategy that works best and appreciate knowing that redraw does not need to be called from the display conduit itself!

You’re right of course, but the OP asked if you should call redraw from the conduit. I think that will lead to an infinite loop, as redraw will I turn call the conduit again.

I think Redraw puts a message on the message pump which will get handled after all other messages (mouse and key events) have been handled. Or if not the message pump some other way to delay the redraw until the current process quiets down.