If I change the code like this (below), only the first run needs the Sleep(1000), others don’t need it and update just fine.
And yes, I need this to run on for many users on different machines, so needs to be bullet-proof.
import Rhino
import rhinoscriptsyntax as rs
def setdegradation(level,sleep):
settings = Rhino.PlugIns.PlugIn.GetPluginSettings(Rhino.RhinoApp.CurrentRhinoId, False)
s = settings.GetChild("Options").GetChild("OpenGL")
s.SetInteger("SkylightShadowResolutionScale", level)
Rhino.PlugIns.PlugIn.SavePluginSettings( Rhino.RhinoApp.CurrentRhinoId)
if sleep:
rs.Sleep(1000)
print "Degradation set to 3"
setdegradation(3,True)
Rhino.PlugIns.PlugIn.RaiseOnPlugInSettingsSavedEvent()
Rhino.RhinoDoc.ActiveDoc.Views.Redraw()
rs.Command("_TestMaxSpeed _Enter")
print "Degradation set to 2"
setdegradation(2,False)
Rhino.PlugIns.PlugIn.RaiseOnPlugInSettingsSavedEvent()
Rhino.RhinoDoc.ActiveDoc.Views.Redraw()
rs.Command("_TestMaxSpeed _Enter")
print "Degradation set to 1"
setdegradation(1,False)
Rhino.PlugIns.PlugIn.RaiseOnPlugInSettingsSavedEvent()
Rhino.RhinoDoc.ActiveDoc.Views.Redraw()
rs.Command("_TestMaxSpeed _Enter")