I have been working recently more with this method, creating some shadow-settings tools: ViewDisplayModeProperty
For some reason the shadows settings set by this script method don’t stick, or basically they revert back after a while. It is tricky and I cannot reproduce exact steps, but every time I change, let’s say, Shadows ON/Off, or the shadows quality, after a short while of working with Rhino, it would revert back to what it used to before the change.
Is it possible that this method is not checking some boxes deeper in Rhino and something else later on reverts/restore the older DisplayMode settings?
Sample script would be:
Dim strCurrentDispMod_ID : strCurrentDispMod_ID = Rhino.ViewDisplayModeEx(,, False)
If Rhino.ViewDisplayModeProperty(strCurrentDispMod_ID, "Lighting\CastShadows") Then
Call Rhino.ViewDisplayModeProperty(strCurrentDispMod_ID, "Lighting\CastShadows", False)
Else
Call Rhino.ViewDisplayModeProperty(strCurrentDispMod_ID, "Lighting\CastShadows", True)
End If
Over here, the toggle would last for a bit, but then Rhino reverts back.
The values reset within a minute or two or continuing working with Rhino, after changing them with that RhinoScript method. Something must be triggering the revert back. I will try to find some pattern that can be repeated. If I change them manually either via Options>Views or Display Panel, they stick forever as they should.
I can reproduce the problem now 100% at least with one condition. It happens not only with shadows, buyt any setting changed by the ViewDisplayModeProperty script method, whether ran as script or compiled plugin.
To try:
Make a box in a mode with cast shadows
run the script above (shadows toggle)
toggle GUMBALL - this reverts the DisplayMode to the state before it was modified by the script.
please note this doesn’t happen if the mode is changed via Display Panel or Display Mode from Options. I am not sure but before it seems like other things also would cause the mode to revert, but so far Gumball is the one I can tell for sure.
Hope that helps to find what the problem was. This method is awesome (if the settings stick!)
i have the same problem with below script which i use to toggle mesh wireframe with a key shortcut. Sometimes it reverts back after using Zoom Extends or when i start to draw a curve…
import Rhino
import scriptcontext
def DisplayModeToggleMeshWires():
dmd = scriptcontext.doc.Views.ActiveView.ActiveViewport.DisplayMode
state = dmd.DisplayAttributes.MeshSpecificAttributes.ShowMeshWires
dmd.DisplayAttributes.MeshSpecificAttributes.ShowMeshWires = not state
Rhino.Display.DisplayModeDescription.UpdateDisplayMode(dmd)
scriptcontext.doc.Views.Redraw()
if __name__=="__main__":
DisplayModeToggleMeshWires()
interesting, so it is not only the RhinoScript method problem, rather something global.
Does Gumball revert things as well on your end with your sample?
Also, does my script snipped and Gumball misbehave on your end?
EDIT: the ZoomExtens or drawing a curve on my end with my sample don’t revert back, only Gumball so far…
Just a guess: If you change any setting in the display tab then all instances of Rhino take over that setting automatically. Don’t know which events trigger that.
If you change any setting by script/rhinocommon this does not happen. Maybe the stored display settings are read back from the registry by various events?
In the past I have noticed there are some disconnects between display panel and viewdisplaymode settings, and now this on top. I am not sure how it all works but my understanding was these are no longer in the registry but rather an xml file? I probably don’t know what I am talking about, but maybe @stevebaer could chime in how to make it all behave ?
Interesting observation @Jess, thanks
Seems like there is more to it than just Gumball. I have a few bigger tools that when I implement this method to change DisplayModeProperty, run just fine while the script is still running, but the display mode reverts back once the script finishes. No gumball involved. But maybe Gumball could give you guys a clue of where to look for a fix?
I used to make these changes via scripting by exporting the DM to ini file, modifying the ini and importing it back. It was much slower and less convenient to use, especially to make many mass-changes, but at least that did stick forever.
I invested decent amount of time to develop some DM-related tools that now are quite useless with these settings not sticking. @dale - hope you will have a chance to look into that or make an YT item.