DisplayModes loading but not showing in menu

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?

I’ve included a couple of example display modes to try:
Example_2.ini (15.4 KB)
Example_1.ini (15.5 KB)

Thanks for any help!

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)

1 Like

Similar issue at my end too. Rhino 8 SR 10

1 Like

Is anyone able to load display modes programmatically in Rhino 8? I’m still experiencing the same issue on Rhino 8 SR 12.

Hi @bfrederick,

All seems to work here.

What am I missing?

– Dale

@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?

Update - I did see this post so maybe it’s still this issue since I am using the ImportFromFile method in the new script editor. DisplayModeDescription.ImportFromFile - Shared Resource - #5 by Gijs

Hi @bfrederick,

This work for me:

#! 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)

– Dale

1 Like