Redraw Freeze in Scripting

I have some scripts where I’m moving objects iteratively in a loop and I want to see the movement by leaving redraw enabled. Problem is, the object will appear to move for a second or two, and then the redraws will stop until the object has reached its final position. It seems like Rhino is putting a limit on the number of redraws it allows you to do in the script. At first I thought that maybe the loop was exceeding the framerate rhino could achieve and I have tried using _testmaxspeed to get a rough idea of the framerate my machine is capable of, and then putting the script to sleep for an appropriate amount of time, but even large pauses of 0.1s dont seem to make a difference. I’ve tried loops both with and without explicit redraw() calls and nothing changes. Can anyone enlighten me as to what’s going on?

Redrawing is pretty low on the totem pole, as far as Windows messages are concerned.

To make sure Rhino flushes it’s message queue, thus forcing to deal with redraw messages, throw a “wait” statement in after you redraw.

If you are using RhinoScript, that would be:

Rhino.Sleep 0

If Rhino.Python, then:

Rhino.RhinoApp.Wait()
2 Likes

Excellent, and informative as usual. Thanks, Dale!

don’t forget you need to import Rhino at the top of your script to use Rhino.RhinoApp.Wait()