I have noticed that the EnableRedraw method will not only redraw the vieports but also seems to be affecting the layers panel. I can see that the selected layer is ‘flickering’ on each redraw. This is distracting and seems to be slowing down the script. I am in a loop with frequent redraw on/off. Would there be any way around this? Is it necessary for redraw to refresh layers panel as well ?
Setting EnableRedraw to False turns off both viewport drawing and layer panel drawing.
Setting EnableRedraw to True turns on both viewport drawing and layer panel drawing, and both the viewports and the layer panel are refreshed so as to show the current state of the document.
I am still running into this constantly with more of the real-time script usage, when doing constant redraw in a loop, if any of the layers in LayerPanel are selected, the ‘flickering’ effect occurs. I was wondering if it would be OK to add an option to Redraw & EnableRedraw methods not to redraw layer panel?
I know in V6 I can check if layers are selected and possibly deselect them, but it is an extra step in the process and sometimes it is not good to lose the layer selection…
You are redrawing the screen, right? Because the screen is already flickering, how big of an issue is this?
In V6, you could get around this by getting the selected layers, un-selecting all layers, doing your redraw thing, and then re-selecting the layers when you are finished…
The screen is not really flickering (the viewport I mean), its just showing placing some objects that follow the mouse… but if any layers are selected, the highlighted ones ‘flicker’ randomly, sometimes just every now and then, sometimes constantly - couldn’t pinpoint any rule.
In V5 there is no elegant way to deal with it other than just manually deselecting layers; in V6 - yes, definitely could work with deselecting-reselecting using the new methods, if there is no option not to redraw the layer panel.
I am revisiting this with more usage and testing of V6. The display speed improvement in V6 is phenomenal, but using what I currently have available via scripting I can’t take the full advantage of it. After more testing I can confirm that the Enable/Disable redraw always causes major slowdown compared to just rotating the view with the mouse or changing the view without enable/disable redraw. Obviously the slowdown culprit is redrawing the UI panels. It can be easily tested and compared with a simple box scene, when you have your Properties and Layers panel on (make sure there are some layers visible, the more the slower redraw is).
Here is a simple script that should help with testing this and seeing the difference, which is more than 2x slowdown (sometimes 6x or more slowdown depending on the model and panels content): Redraw_vs_EnableRedraw.rvb (2.2 KB)
Even when working in FullScreen with no panels visible, using EnableRedraw/DisableRedraw is a slowdown compared to no redraw performance.
In most cases in our toolset I need to turn off the redraw because the camera or objects change is not a one-step, but several transformations before the view can be refreshed, so can’t avoid having to enable-disable redraw.
Here comes the wish:
Could we add a method that allows redrawing just the viewport or all viewports, without redrawing the rest of the UI?
Something of what I guess would be an equivalent of RhinoCommon: scriptcontext.doc.Views.Redraw() view = __viewhelper(view) view.Redraw()
Having that would make it possible to take full advantage of the V6 new display speed improvement via RhinoScript, if possible to add to any of the upcoming SRs. Hope you find it a reasonable request.
The EnableRedraw/Redraw difference is clear (maybe my testing code was confusing since I was trying all combinations to see any differences). The visible slowdown is caused no matter if Redraw, EnableRedraw (or unnecessarily both) are used.
Updated Rhino.Redraw will be great to have. So it will basically redraw just viewports if such option is selected, correct? (I can’t tell if any other panels like Properties are also refreshed currently on Redraw…)
Just tested the upgraded Redraw method with False for fast redraw. Something seems off…
There is zero speed gain / difference whether I use old Redraw of the new one with False for views only.
Apart from that, calling Redraw(True or False) seems to be enabling redraw in general.
It shows if you do a few step camera modification (Zoom in the test below). Before it did not behave like that.
Sub TestJarek
Dim nResult, bRedraw, tmStart, tmEnd, i
nResult = Rhino.MessageBox("Enable redraw?", 3 + 32)
Select Case nResult
Case 6 ' Yes
bRedraw = True
Case 7 'No
bRedraw = False
Case Else
Exit Sub
End Select
If Not bRedraw Then
Call Rhino.EnableRedraw(False)
End If
tmStart = Timer
For i = 1 To 100
Call Rhino.RotateView(, 0, 10.8)
If Not bRedraw Then
Call Rhino.Redraw(False)
End If
Next
tmEnd = Timer
If Not bRedraw Then
Call Rhino.EnableRedraw(True)
End If
Call Rhino.Print("Elapsed time: " & FormatNumber(tmEnd - tmStart, 2) & " seconds")
End Sub