Redraw and Layers panel

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 ?

thanks,

–jarek

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.

Hi Dale,

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…

–jarek

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…

– Dale

Hi Dale,

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.

thanks,

–jarek

Hi @Dale,

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.

Thanks,

–jarek

Hi @Jarek,

1.) Rhino.Redraw redraws all views and refreshes the layer panel. Note, this works when screen redrawing is disabled.

2.) Rhino.EnableRedraw True turns on screen redrawing and then (basically) calls Rhino.Redraw.

Thus, doing this is:

Rhino.Redraw
Rhino.EnableRedraw True

Will redraw all views and refresh the layer panel twice.

I don’t change the behavior of Rhino.EnableRedraw. When set to True everything should be updated.

But I will add an option to Rhino.Redraw that allows you to control whether or not the layer panel is refreshed, which can be time consuming.

https://mcneel.myjetbrains.com/youtrack/issue/RH-45312

– Dale

1 Like

Hi @Dale,

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…)

Thanks!

–jarek

Yep.

– D

1 Like

Please add this to Python rhinoscriptsyntax as well as scriptcontext.views.Redraw() too please!

RH-45312 is fixed in the latest Service Release Candidate

Hi @Dale,

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.

Here is a comparison:

And the revised testing script with the new Redraw as an option:
Redraw_vs_EnableRedraw_vs_FastRedraw.rvb (2.9 KB)

Do you see anything that might be causing the slowdown and enabling redraw in the improved method?

Thanks,

–jarek

Hi @Jarek,

I think your test is flawed. Try this:

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

– Dale

1 Like

Hi @Dale,

thanks, and you are right, I was too eager to test it last night and the test did not disable redraw before spinning…

here is the fixed test if anyone wants to try:
Redraw_vs_EnableRedraw_vs_FastRedraw.rvb (3.1 KB)

The new redraw is blazing fast compared to what we had access to before!!
Thank you for enabling this.

–jarek

@dale,

How do I access this improvement in Python? Rhino.Redraw does not exist, even with an

import Rhino statement

at top. I use

doc.Views.RedrawEnabled = True

successfully in my Python script so I tried

doc.Views.Redraw = False

but this fails with the message:

Message: attribute ‘Redraw’ of ‘ViewTable’ object is read-only

Please, what is the Python script equivalent for Rhino.Redraw(False)?

I tested your TestJarek on my system and definitely see an improvement. It would be very nice to harness this in my Python scripts.

Regards,
Terry.

@dale,

How do I access this improvement in Python? Rhino.Redraw does not exist, even with an

import Rhino statement

at top. I use

doc.Views.RedrawEnabled = True

successfully in my Python script so I tried

doc.Views.Redraw = False

but this fails with the message:

Message: attribute ‘Redraw’ of ‘ViewTable’ object is read-only

Please, what is the Python script equivalent for Rhino.Redraw(False)?

I tested your TestJarek on my system and definitely see an improvement. It would be very nice to harness this in my Python scripts.

Regards,
Terry.

This should look like this:

doc.Views.Redraw()

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_DocObjects_Tables_ViewTable_Redraw.htm

– Dale

1 Like

What if False is not desired. What would it be in that case?

Sorry @Terry_Chappell, I don’t understand your question.

– Dale

Hi @Terry_Chappell, try this to disable (False) or enable (True):

scriptcontext.doc.Views.RedrawEnabled = False

To get the current state, you can query it using the same code:

redraw_enabled = scriptcontext.doc.Views.RedrawEnabled 

I guess you can redraw single views too, which does not redraw the layers panel:

scriptcontext.doc.Views.ActiveView.Redraw()

_
c.