RS: ViewDisplayModeProperty settings don't last

unhandled

#1

hi @dale

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.

Any ideas?

–jarek


(Dale Fugier) #2

Hi @Jarek,

Sorry, I don’t have any ideas on this. Are the values reset after installing a SR? If you set them manually do they get reset?

– Dale


#3

Hi @dale

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.

–jarek


#4

hi @dale

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:

  1. Make a box in a mode with cast shadows
  2. run the script above (shadows toggle)
  3. 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!)

–jarek


#5

Hi @Jarek and @dale,

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()

_
c.


#6

hi @clement

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…

thanks,

–jarek


#7

Hi @Jarek, yes i can repeat this with my script and gumball disabled:

  1. Make a mesh box
  2. Run my script to toggle the mesh wireframe
  3. Enable Gumball from the StatusBar
  4. As soon as i click an object, the mesh wireframe toggles back

If the gumball is enabled already before step 1, i can repeat the same behavior by turning gumball off in step 3.
_
c.


#8

hi Clement, thanks for testing! Hope it helps to sort out what the problem is.

–jarek


#9

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?


#10

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

–jarek


#11

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.

thank you,

–jarek