Redraw and Layers panel

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

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.

This seems to work:

import Rhino
import scriptcontext as sc

sc.doc.Views.RedrawEnabled = False

plane = Rhino.Geometry.Plane.WorldXY
circle = Rhino.Geometry.Circle(plane, 5.0)
sc.doc.Objects.AddCircle(circle)

sc.doc.Layers.Add()

sc.doc.Views.RedrawEnabled = True

Setting RedrawEnabled = True will redraw the document and refresh the layer panel (if it is open).

– Dale

@dale
My use of False refers back to the Rhinoscript usage further up in this post:

Call Rhino.Redraw(False)

For Python use what I am getting is the following:

To turn redraw back on and do a redraw of all views with panels included I use:

from scriptcontext import doc
doc.Views.RedrawEnabled = True

while to redraw all views without panels I use:

doc.Views.Redraw()

and to redraw a single view without panels I use:

doc.Views.ActiveView.Redraw()

Please let me know if this is not right or if there are simpler or additional ways that would be interesting to consider.

Thanks,
Terry.

hi @Dale,

Following up about the Redraw update to RhinoScript - the modification you made to enable redrawing of only viewport and not UI was a game changer for the interactive scripts that rely on constant viewport updates. In allows now to do really cool things with that, with no slowdown.

One thing I have been running into, and potentially a wish-pile item for V7 if possible, is the ability to run Rhino.EnableRedraw without actually redrawing the views/UI, or with just redrawing views but not UI. Most of the tools that take advantage for the fast redraw still work like:

Rhino.EnableRedraw False
Start Loop
   Do Something
   Redraw False (fast redraw)
End Loop
Rhino.EnableRedraw True

So the last line always results in the full redraw, and very noticeably a blink in the Layers panel if any layers are highlighted.
The wish would be to be able to re-enable redraw with either no instant redraw or just “views only” redraw. Maybe an additional argument in the EnableRedraw method?

thanks again

–jarek

@Jarek - I added your wish to the pile.

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

– Dale

Thanks!