Clear cache / visualisation - Rhino + Python

Hi, I am trying to create a simple python script where I would like to have points moving through space given certain rules.

I am running a “for i in range loop”, given the number of step my points have to go through, and I am performing all the operations during each step with enable redraw = false.

At the end of each step I am

  • enabling the redraw to show only the new positions plus a trail,

  • pausing the loop with a time.sleep(n-seconds)

  • disabling the redraw

  • running the loop again.

The problem is that sometimes, even if it should show what is happening-pause-run again, the redraw just shuts off and the script run until the last loop and then shows the final results.

The only way I found at the moment to keep him working a bit longer is adding a gc.collect(), but I was wondering if there are other way to clean the rhino cache as well (provided it is that that disable the preview of what is happening), or anyway clear garbage data that is piling at each step.

Just to recap the structure would be:

for a certain number of steps

perform some operations

show the results

pause/clear the garbage

hide the visualisation

Thanks in advance

V.

What you can try is importing the Rhino module (if you haven’t already) then use

Rhino.RhinoApp.Wait() at the point in the loop where you want it to redraw, then your time.sleep() after.

In theory at least, RhinoApp.Wait() should let the display catch up before continuing the next loop.

–Mitch