Toggle between rendered and wireframe?

Is it possible to toggle between rendered and wireframe display and assign that to a toolbar button? Left click to go to rendered; left click again to go to wireframe. I’d also like to do the same on the right-click, but make that work for selected objects only, if that’s possible. This is for V8

I used to do something similar in V5, but that didn’t “stick” - as soon as I clicked somewhere in the viewport or hit enter, the display would revert from rendered to wireframe. I think the above would be more useful to me nowadays.

You may try this and see if it does the job for you:

Cycle display modes (this is assigned to the left mouse button in my Rhino 7):
CycleDisplayModes.py (1.4 KB)

Set cycle modes (this is assigned to the right mouse button in my Rhino 7):
SetCycleModes.py (2.4 KB)

I use the following icon:
Cycle viewport modes

The “Set cycle modes” script (activated with the right mouse button) gives you the ability to open a vertical list with all the available display modes and then choose which ones of them will be switched by the other script.

2 Likes

This works really well and is very flexible. Thanks Bobi.

I’m not sure how best to accommodate a “one hit” method for shading selected objects by this method. I’ll have to have a think about that.

1 Like

Hi @MattE,

This is a bit more tricky as it needs to allow for “Use View” (no custom mode assigned)…

Please try if it does the trick with this script:
ToggleObjectDisplayModes.rvb (4.5 KB)

(to install, save it on your HD and drag-and-drop into Rhino. The new alias command will be ToggleObjectDisplayModes)

At first run it will ask you to define the modes to cycle thru.
Then, the macros for button or shortcut should be:

  • ToggleObjectDisplayModes TOGGLE

Or to redefine the modes:

  • ToggleObjectDisplayModes DefineModes

hth,

–jarek

2 Likes

Many thanks Jarek! I’ll take a look and report back…

Hi Jarek. How do I call the “Toggle” and “DefineModes” options within a macro, to assign to a button?

did you try these?

Yes, but I’m not sure of the correct syntax. When I assign these excatly as you’ve written them to a button, I get “Unknown command: Toggle” on the command line. The basic command ToggleObjectDisplayModes is listed in Options > Aliases.

If I follow the command, I’m prompted to select objects, then hit enter. Then I’m prompted to select TOGGLE or DefineModes on the command line, then enter again. That works, but there are a lot of mouse clicks and to deselect and go back to wireframe, I have to go through the whole sequence again, including picking objects. Pre-selecting objects doesn’t seem to work; that would be my preferred option, as it’s a “shade selected” type of command, which infers that objects are already selected.

Hi @MattE,

I am not sure what’s going on - the preselection should work, otherwise the whole thing doesn’t make sense as you always want to run this on selected objects. Sure, it will ask for selection if nothing is selected, but then there will be many more clicks and "unknown command’ with these macros.

Seems like you have it installed OK since the command it working (Alias added and in Options > RhinoScript the original script is preloaded at Rhino start, correct?)

So the macros are:
_ToggleObjectDisplayModes TOGGLE
_ToggleObjectDisplayModes DefineModes

I just tested all again in V8, seems to work fine, especially with preselection, it even works while you are inside any command in Rhino.

Here is how it is supposed to behave (when assigned to a button, but may as well be a key shortcut):

Does it help?

–jarek

2 Likes

You’re right, Jarek. It is working correctly. I just need to get used to the flow of the command, and the fact that it behaves quite differently depending on whether one has preselected objects or not.

I’m used to using my old macros, which weren’t persistent. They were one-hit calls that would shade the selected objects. As soon as one hit enter, or clicked off of the objects, or called another command, the “render preview” ended and one was back in wireframe. I often find it easier to point edit in wireframe so that I can easily see the control points and their polygons. I then quickly dip in and out of a shaded mode to see if I’m getting close to what I want in terms of appearance. For that, the non-persistent command worked well for me. On other occasions, that approach would not be so good - then I would switch the viewport to a permanent shaded view of some description.

Your .rvb is a half-way house. If I preselect objects, I can dip in and out of the shaded mode, and even using Enter will flick me in and out of it. However, if I haven’t preselected objects, that work flow, including using Enter, sets me off on a very different path. It keeps prompting me to select objects and whether I want to toggle or define modes. That is what was throwing me. I hope that makes sense!

I like these scripts - both yours and @Rhino_Bulgaria . They open up different ways of working. I just need to adapt to the functionality they bring. Thank you both!

Matt

What about point editing in Wireframe mode and then run the “Shade” command with you preferred display mode assigned to it, in order to see a quick preview of the modified object’s appearance? Once you are done with the observation, you can cancel the “Shade” command easily.

That’s pretty much what these scripts allow me to do! :+1:

Because they toggle the shaded mode (or now modes), hitting enter takes the display back to wireframe while I’m “in command”. If I want them to stick, I leave the shaded mode in effect, but I can toggle out of it by hitting the same button again when I’m done. I get the best of both worlds.

I like the fact that I can change the shaded mode that’s loaded purely from the buttons, but the button on my popup is still the same, no matter what shaded mode or modes I’ve preselected. That’s very neat. And it’s all very easy to change.

1 Like

I found that there is a bug with this script. For some reason it will apply the environment map of the selected display mode to all the rest (non-selected) objects. I tested the script with various custom display modes and looks like it works best with those that don’t utilize an environment map. :slight_smile: For example, if I set Crackdown 5.ini as an object display mode, selecting that object will trigger the display mode to all objects in the scene, although the expectation is that they will remain unaffected.

Here is a short video that shows the issue:

Hi Bobi,
Seems like this is a V7 display bug in general, not script-related. The script does nothing to mess with this. If you try to assign per-object display mode ‘by hand’, using Rhino command and not script, you will see the same problem.
I could not repeat this in V8 but hey, I could not test it too much since V8 crashes every time I switch to Renderings tab.

Hi @MattE,

Here is a modified approach - instead one command with 2 options, it is better to split it into 2 separate commands - this way whether you preselect or not, the Toggle will happen as expected, no Unknown Command and less clicks. To define modes use a separate command.

ToggleObjectDisplayModes.rvb (2.8 KB)
ToggleObjectDisplayModesDefineModes.rvb (3.1 KB)

Same as before, save each on HD and drag-and-drop to install. You should overwrite the old one with this one just to be safe.

The aliases will just be the script names:

_ToggleObjectDisplayModes
_ToggleObjectDisplayModesDefineModes

It’s an interesting idea, thanks for suggesting - it could be combined with another toggle that disables selection highlight (I posted a script for that somewhere as well) so instead we can have just a custom display mode for selected stuff - can be handy when moving dense meshes or navigating complex models in general…

hth,

–jarek

1 Like