Cannot disable redraw in Rhino 6

Hi, I have a script that disables redraw for speed while it creates geometry, then enables it again afterwards:

import rhinoscriptsyntax as rs
rs.EnableRedraw(False)
…do stuff…
rs.EnableRedraw(True)

In rhino 5 it works as expected.
However when I run the same script in rhino 6 I can see the geometry being created in front of me on screen (and it takes minutes to complete, as opposed to seconds in rhino 5) - redraw is not disabled.

Is there something I’m not aware of here? Does redraw() behave differently in rhino 6 than it does in rhino 5?

In case it’s relevant, here is the OpenGL info from options in rhino 5:

And in rhino 6:

Hmm, I guess we would need the script to see what operations are being called that could cause this behavior…

1 Like

Here is a video of the same script running side by side in rhino 5 (left) and rhino 6 (right). Video is 80 seconds, it ends when the script is complete in rhino 5.

You can see that redraw is disabled in 5, but not in 6.

Something I noticed only after making this video and watching it - different surfaces are having colour applied to them depending on whether the script is run in 5 or 6! In 5 it’s the upper surfaces that are all magenta (which is correct), in 6 it’s the lower surfaces that are all magenta (which is incorrect).

At first I thought I must have somehow run two different scripts (which is why I quickly edited my post above, now deleted - although at no point have I ever written a version of this script that leaves the bottom surface as magenta), but I have doubled check this behaviour and am 100% certain they are running the same script (I have dragged the same .3dm model file from windows explorer into the rhino windows to open them, and closed all script files in the editors for each, then renamed the script file in explorer to something unusual and unique and then opened it in the editor for 5 and 6 - definitely the same script file.

So now the added difference in behaviour of colour being applied to different surfaces, using the same script file. There is no logic in my script that checks or refers to the rhino version in any way at all.

Curioser and curioser.

The colouring difference was down to rhinoscriptsyntax.SplitBrep() returning results in a different order in rhino 6 to the way it did it in rhino 5.

The difference in behaviour between 5 and 6 that results in redraw remaining enabled in 6 is still a mystery though.

Video of the version corrected for the SplitBrep() changes

Rhino 5 on the left with redraw disabled, rhino6 on the right running the same script with redraw not disabled.

In my code I have this line:

rs.Command(’_-Export {} _Enter’.format( frameFullPath ))

If I comment it out redraw behaves as expected (same as rhino 5).

Someone please correct me if I’m wrong but I believe this is a bug in Rhino 6.

Here is code that demonstrates the behaviour:

import rhinoscriptsyntax as rs
import scriptcontext

def main():	
	rs.EnableRedraw( False )	
	doStuff( )		
	rs.EnableRedraw( True )	
	return 0
		
def doStuff( ):	
	for i in range( 0, 10 ):		
		if (scriptcontext.escape_test(False)): break			
		s = rs.AddSphere( [ 100*i , 0, 0 ] , 30 )		
		save( )			
	return 0
		
def save(  ):		
	rs.AllObjects( True )
	rs.Command('_-Export {} _Enter'.format( "temp.3dm" ))			
	return 0
	
main()

If you run as shown in Rhino 6 redraw will not be disabled, you’ll see each sphere being individually drawn.
If you comment out the rs.Command line redraw will be disabled as expected.

If you run this in rhino 5 it makes no difference whether the line is commented out or not, redraw is correctly disabled.

1 Like

From what I can determine, it is actually the Export command itself that is provoking the redraw, not rs.Command(). In my tests here, if I run the rs.Command with something other than Export or SaveAs, no intermediate redraw happens. So this might be a change made to the Export/SaveAs command mechanisms for V6. @dale?

Yes, I also use rs.Command() to attach files to a worksession in the same script and they don’t cause any issues.

Hi @fergus.hudson

Thanks Mitch for checking this. I have been running into this issue as well and solved it by putting in some extra code lines for redraw disable code. I never found it was th Export command causing it
@dale
If possible It would be good to know what commands re-enable the redraw to target only those.

-Willem