Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 4118

How to change display mode using script?

$
0
0

Hello,
I’m new to Rhino. I am trying to write a python script that changes the display mode to user-chosen display mode (by display mode I mean “rendered”, “wireframe” etc.
I tried to use some script I found online:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import os
import Rhino

def SetDetailsToWireframe(debug):
modes = rs.ViewDisplayModes()
setmode = rs.ListBox(modes, “Select mode”)
# Find the chosen display mode
display_mode = Rhino.Display.DisplayModeDescription.FindByName(setmode)
if display_mode:
DebugPrint(display_mode, debug)
# Get all of the document’s page views
page_views = sc.doc.Views.GetPageViews()
if page_views:
# Process each page view
for page_view in page_views:
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:
# …set it to wireframe.
detail.Viewport.DisplayMode = display_mode
detail.CommitViewportChanges()
# Redraw the page
page_view.Redraw()

but the display mode didn’t change, and in the first debug print (of the display_mode) I got:
Rhino.Display.DisplayModeDescription object at 0x0000000000000089 [Rhino.Display.DisplayModeDescription]
I am using Rhino7 on windows.
What am I doing wrong?

thanks

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4118

Trending Articles