Change view settings via a script

I wish to access this specific setting via a script, so I can enable/disable it.

I have been in here Rhino.Display.DisplayModeDescription.GetDisplayModes()

And in there I tried the dm_table[0].DisplayAttributes

but with no luck. Any good advice?

import Rhino
mode = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.DisplayMode
mode.DisplayAttributes.HighlightSurfaces ^= True # toggles bool value
mode.DisplayAttributes.MeshSpecificAttributes.HighlightMeshes ^= True # toggles bool value
Rhino.Display.DisplayModeDescription.UpdateDisplayMode(mode)
2 Likes

that script sets the “true” to the currently used display mode - if i get it right?
but how to change the settings of the shaded mode , weather its currently used or not
(does my question make sense?)

mode = Rhino.Display.DisplayModeDescription.FindByName("Shaded")

thank you.
but I dont get it. sorry.
now it looks to me as if its not part of the active document any more?

The FindByName() method will search in the active document display modes.

1 Like

thank you,
it works - and I understood a bit more.

FYI the method I came up with to solve this was to make a copy of shaded with those boxes checked and then use this script to compare the two display mode objects and find out what attributes were different between them. Seems like a good general-purpose solution for this sort of thing, so I thought I’d share it.

def compare(obj1, obj2):
	tab = "    "
	for attr in dir(obj1):
		if not hasattr(obj2, attr):
			print(attr)
			print(tab, getattr(obj1, attr))
			print(tab, "<no attr>")
			continue
		value1 = getattr(obj1, attr)
		value2 = getattr(obj2, attr)
		if value1 != value2 and "method" not in str(value1):
			print(attr)
			print(tab, getattr(obj1, attr))
			print(tab, getattr(obj2, attr))
	for attr in dir(obj2):
		if not hasattr(obj1, attr):
			print(attr)
			print(tab, "<no attr>")
			print(tab, getattr(obj2, attr)
2 Likes

Why did I not think about this. This is such a good way to do it. Of course!!! Thank you!

1 Like