Yes, this is for real-time viewport stuff and need to relatively seamlessly swtich between the degradation modes.
Yes That was the key! You really did the maximum! Thank you so much. No more questions, now it does exactly what I needed it to do, with no delay to update at all.
The trick is to add:
Rhino.RhinoApp.Idle
rs.Sleep(0)
right after this line: Rhino.PlugIns.PlugIn.SavePluginSettings( Rhino.RhinoApp.CurrentRhinoId)
So the final sample code would be:
import Rhino
import rhinoscriptsyntax as rs
def setdegradation(level):
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)
Rhino.RhinoApp.Idle
rs.Sleep(0)
print "Degradation set to 3"
setdegradation(3)
Rhino.PlugIns.PlugIn.RaiseOnPlugInSettingsSavedEvent()
rs.Command("_TestMaxSpeed _Enter")
print "Degradation set to 2"
setdegradation(2)
Rhino.PlugIns.PlugIn.RaiseOnPlugInSettingsSavedEvent()
rs.Command("_TestMaxSpeed _Enter")
print "Degradation set to 1"
setdegradation(1)
Rhino.PlugIns.PlugIn.RaiseOnPlugInSettingsSavedEvent()
rs.Command("_TestMaxSpeed _Enter")
Adding it after Rhino.PlugIns.PlugIn.SavePluginSettings( Rhino.RhinoApp.CurrentRhinoId), before rs.Sleep seems to do the trick.
Then the setting actually triggers in Vport after you run the Rhino.PlugIns.PlugIn.RaiseOnPlugInSettingsSavedEvent()
If you need to change the advanced options, the code is almost identical to Python:
// get settings
Rhino.PersistentSettings settings = Rhino.PlugIns.PlugIn.GetPluginSettings(Rhino.RhinoApp.CurrentRhinoId, false);
Rhino.PersistentSettings options = settings.GetChild("Options");
Rhino.PersistentSettings openGl = settings.GetChild("OpenGL");
// set value
openGl.SetInteger("SkylightShadowResolutionScale", 2);
// reload the interface and apply the changes
Rhino.PlugIns.PlugIn.RaiseOnPlugInSettingsSavedEvent();
If you need something else you’ll have to be a little more precise.
If you are running outside of Rhino, then you need to find and edit the settings XML file. The settings file is typically located at %AppData%\McNeel\Rhinoceros\6.0\settings