BETA: Command line flicker with Prompt/Cmd History loop via RhinoScript

Hi,

I’m testing one of my legacy RhinoScript-based viewport navigation plugins with Rhino 9. It continuously updates the command prompt and command history to display real-time navigation information.

In Rhino 9, these updates cause noticeable flickering in the command-line interface, whereas the same functionality worked smoothly in previous Rhino versions.

I’ve isolated the relevant code into a minimal RhinoScript test (attached).
CommandLineFlickerTest.rvb (2.2 KB)

The script repeatedly uses:

  • Rhino.Prompt() to update the prompt.

  • Rhino.CommandHistory() to read the history.

  • Rhino.ClearCommandHistory() to clear it.

  • Rhino.Print() to display updated information above the prompt.

It runs in a loop until Esc is pressed.

I’m wondering if this is related to changes in Rhino 9’s command-line UI rendering, and whether anything could be adjusted on Rhino’s side to restore the previous smooth behavior without flickering.

I’d prefer to maintain compatibility with my existing RhinoScript code rather than having to redesign the plugin’s interface.

PS. If I try to replicate similar test in Python using RhinoCommon, there is no flicker:
RhinoCommonTest_NoFlicker.py (2.8 KB)

thanks,

–jarek

Hi Jarek,

In Rhino 9 the command history redraws every time a RhinoScript method is called. Your loop calls Rhino.ClearCommandHistory and then Rhino.Print 11 times, so on each refresh the history is drawn empty, then with 1 line, 2 lines, and so on up to 11. Those in-between states are the flicker.

Your Python version runs with # async: true, so it runs on a background thread, and the history only gets redrawn once the updates are done. That’s why it looks smooth.

The workaround is to skip the clear and send everything in a single Print call:

' ---------------------------------------------
' Rebuild command history
' ---------------------------------------------

Call Rhino.Print(String(10, vbLf) & strInfo)

This replaces the Rhino.ClearCommandHistory() call, the For loop, and the Rhino.Print(strInfo) line. The history then only ever shows complete blocks, with the mouse information on the bottom line. The history text does grow over time, but Rhino trims it once it gets to about 65,000 characters.

Also, in the current Beta, Rhino.Sleep(100) can return before 100 ms are up. So the loop may refresh more often than intRefresh suggests.

– Dale

For posterity, I’ve filed this as RH-99806 so I can take a look to see if we can make improvements here.

The main culprit of a rvb script is that every call pumps the message loop (as @dale mentioned). None of the other scripting languages do that so even without # async: true you’d probably get a smoother output since it would only update during your call to Rhino.Sleep().

Thanks for raising the issue.

Hey @Jarek,

So I’ve looked into this, and it is only happening because RhinoScript pumps the message loop on every method call, which then updates the UI. You’re only seeing this because the new command history updates faster visually.

This doesn’t happen on any of the more modern scripts (py2, py3, and c#) even without running in a background thread since you can call RhinoApp.Wait() when you want the UI to update.

I’ve investigated some options to get around this such as throttling updates, but then it can sometimes update as blank for longer which is an even worse problem, and makes the command history feel sluggish.

So, unfortunately there’s not much we can do here to fix the old script engine without breaking things, and any updates to the command history just feels like a step backwards. Dale’s suggestion of writing all lines in one go is maybe a middle ground that might help with your old scripts.

Hope this helps.
Curtis.

Hi Dale and Curtis,

Thank you for looking into it. For now, I tested Dale’s workaround and eliminating the ClearCommandHistory fixes the flicker effect. It was not critical to have after all, so thank you for suggesting that. I think I can work with.

thanks again-

–jarek