Switch displaymode next/prev. by key

Is there a method to set the next displaymode by key or macro?

The wish is to have i.e. Shift+F4 to switch from Wireframe to Shaded to Rendered to…
And Shift+F5 for the other way around.

With a script it should be possible. One could either iterate through the list of all display modes set up, or hard code a more limited list of display modes in the script if one only wanted to cycle through a few.

Also need to decide whether the display mode si to be applied to all viewports or just the active one.

However Shift+FXX does not seem to be available via Rhino’s keyboard shortcuts, only Ctrl+FXX (or Ctrl+Shift).

Hi Charles - here is a thing from my pile that you can try, along the same lines as Mitch suggests - set the modes to cycle with one script and cycle them with the other.

CycleDisplayModes.zip (1.7 KB)

To use the Python script use RunPythonScript, or a macro:

_-RunPythonScript "Full path to py file inside double-quotes"

I guess it needs a tweak to be able to go both ways in the list, I’ll have a look.

-Pascal

Thanks Pascal, the script combination works well.
I like the preselection of modes!
Very good solution.

This doesn’t work at all.
_-RunPythonScript "T:\Desktop\SetCycleModes.py"
image

Hm… new to me, I’ll check.

-Pascal

Also in (8.6.24079.11001, 2024-03-19).

I tried in V7 (7.37.24004.15001, 2024-01-04), same error.

In the V7 Rhino Python Editor I get the error message, in V8 it simply runs.

Wasn’t there a thing with different Python versions (2/3 or so)?

_EditPythonScript in V8 shows the same behaviour.

See here, seems to be the same thing:

If by any chance you put this at the very top of the script does it help?

#!/usr/bin/env python
# -*- coding: utf-8 -*-

I’m wondering if what you are seeing is that one or more of your display modes has some non-ascii character or something. Just a shot in the dark.

Nope, that’s not it.

I commented out this line in SetCycleModes.py:
english_name = english_name.translate( "_ -,.")

Now it runs as expected.
I’ll try to find out what translate is supposed to do.

1 Like

@pascal
Can you please explain/comment/solve this?
I couldn’t find out about the translation table.

This is translate: Built-in Types — Python 3.10.13 documentation

I’m not entirely sure how it is supposed to be used in the shared code.