When running the following code in Rhino 8, 8.8.24163.12481 I’m able to load display modes by file programmatically but it does not show up in the menu; despite the InMenu property being True This same code works fine in Rhino SR 37 for me.
Based on other examples here I thought this implementation would work but maybe i’m doing something wrong?
import rhinoscriptsyntax as rs
import Rhino
from System import Guid
# get the display mode files
display_mode_filepaths = rs.OpenFileNames("Select Display Modes to Load", "Rhino Display Mode Files (*.ini)|*.ini||")
# load the display modes
for display_mode_path in display_mode_filepaths:
imported_display_id = Rhino.Display.DisplayModeDescription.ImportFromFile(display_mode_path)
if isinstance(imported_display_id, Guid):
display_mode = Rhino.Display.DisplayModeDescription.GetDisplayMode(imported_display_id)
display_mode_id = Rhino.Display.DisplayModeDescription.AddDisplayMode(display_mode)
print("Display Mode '{}' In Menu: {}".format(display_mode.LocalName, display_mode.InMenu))
if isinstance(display_mode_id, Guid):
print("Display mode loaded successfully.")
else:
print("Unable to add display mode")
else:
print("Somethign went wrong loading the display modes.")
# print current display modes in document
for display_mode_description in Rhino.Display.DisplayModeDescription.GetDisplayModes():
print(display_mode_description.LocalName)
@dale Here’s some more detail, I was using the #! python3 flag in the new script editor and it wasn’t working. I just switched to #! python2 and the display modes appeared in the dropdown then upon opening the dropdown again they disappear. Wondering if you can replicate that behavior?
#! python3
import rhinoscriptsyntax as rs
import Rhino
from System import Guid
# get the display mode files
display_mode_filepaths = rs.OpenFileNames("Select Display Modes to Load", "Rhino Display Mode Files (*.ini)|*.ini||")
# load the display modes
for display_mode_path in display_mode_filepaths:
imported_display_id = Rhino.Display.DisplayModeDescription.ImportFromFile(display_mode_path)
if isinstance(imported_display_id, Guid):
display_mode = Rhino.Display.DisplayModeDescription.GetDisplayMode(imported_display_id)
display_mode_id = Rhino.Display.DisplayModeDescription.AddDisplayMode(display_mode)
print("Display Mode '{}' In Menu: {}".format(display_mode.LocalName, display_mode.InMenu))
if isinstance(display_mode_id, Guid):
print("Display mode loaded successfully.")
else:
print("Unable to add display mode")
else:
print("Somethign went wrong loading the display modes.")
# print current display modes in document
for display_mode_description in Rhino.Display.DisplayModeDescription.GetDisplayModes():
print(display_mode_description.LocalName)