Python - changing display mode of all views




I’ve recently found a snippet of code online here: Change all detail view display modes

And I’ve attempted to copy the final version into my code.

I would like to be able to change the following:

To a rendered view:

Here is my (copied) function for doing so:

def SetDetailsToRendered(debug):
modes = rs.ViewDisplayModes()
setmode = rs.ListBox(modes, “Select mode”)
# Find the wireframe display mode
display_mode = Rhino.Display.DisplayModeDescription.FindByName(setmode)
if display_mode:
MessageBox.Show(“display mode”)
DebugPrint(display_mode, debug)
# Get all of the document’s page views
page_views = scriptcontext.doc.Views.GetPageViews()
if page_views:
MessageBox.Show(“Page views”)
# Process each page view
for page_view in page_views:
MessageBox.Show(“Page view”)
DebugPrint(page_view, debug)
# Get all of the page view’s details
details = page_view.GetDetailViews()
if details:
# Process each page view detail
for detail in details:
DebugPrint(detail, debug)
# If the detail’s display mode is not wireframe…
if detail.Viewport.DisplayMode.Id != display_mode.Id:
MessageBox.Show(“if id = id”)
# …set it to wireframe.
detail.Viewport.DisplayMode = display_mode
# Redraw the page

def DebugPrint(object, debug):
if object and debug:
print object

I have attempted a few MessageBoxes to see if it’s going through all the if statements and loops. I’ve noticed it doesn’t get past the “display mode” message box. So it doesn’t go into “if page_views” statement.

I’m trying to understand what a page view exactly is and why I’m not getting one. Any help would be greatly appreciated.

This is implemented using Rhino 6 WIP. I hope it still works the same as 5.



(Dale Fugier) #2

Hi Jack,

The sample code you reference changes the detail views found in layouts. It looks like you are just wanting to modify model views, not details view. Is this correct?

– Dale


Yes Dale,

Since I’m not too familiar with Rhino it looks like I’ve gotten detail views and model views mixed up.

Thanks for that clarification.

I will continue looking for solutions but if you have any ideas I would be very happy.


I have this code for changing all model views to a particular display mode:
(example in this case for “Shaded”, you can substitute whatever mode you need)

import rhinoscriptsyntax as rs
views = rs.ViewNames()
if viewtype in modes:
    for view in views:
        rs.ViewDisplayMode(view, viewtype)



I use a simplified version of this in all my scripts, you just have to get the type of view correct when using it.

for view in rs.ViewNames(): rs.ViewDisplayMode(view, ‘Shaded’)