Keyboard shortcuts (toggle different functions)

How can I create a keyboard alias that toggle between two different command?
Example:
I want the “Z” key to toggle wireframe/shaded, just like F7 tuns on/off the grid.
Does it needs a script for doing so? If it does, how to do it?

You can try this quick script hack… If the viewport is neither in wireframe or shaded (like say ghosted), it will set it to wireframe. It could also be changed to just ignore your request if the viewport is in neither of the two modes…

–Mitch

Option Explicit
'Script by Mitch Heynick ©
'Version 3 February, 2014

Call ToggleWireframeShaded()
Sub ToggleWireframeShaded()
	Dim currView, currDMode
	currView = Rhino.CurrentView()
	currDMode = Rhino.ViewDisplayMode(currView)
	If Not IsNull(currDMode) Then
		If currDMode = 0 Then
			Call Rhino.ViewDisplayMode(currView, 1)
		ElseIf currDMode = 1 Then
			Call Rhino.ViewDisplayMode(currView, 0)
		Else
			'Current view mode is neither wireframe or shaded
			'Set view to Wireframe mode
			Call Rhino.ViewDisplayMode(currView, 0)
		End If		
	End If
End Sub
1 Like

Mitch!
This possibility is fantastic!
The problem is that I’ve never used scripts before, so I don’t know how to load then into Rhino. Worst, have no idea how to call a script from the aliases window.
PS: I’ve heard Rhino is able to support python, and I know it. Where can I find some samples on scripting with python?
– Joddy

OK, the attached is set up for drag and drop. Save the file in a directory where you have access and where it will “live” - like

C:\Users\<username>\AppData\Roaming\McNeel\Rhinoceros\5.0\scripts

or somewhere else where it will stay…

Then from there, drag it into a running Rhino window. You will then have an alias “ToggleWireframeShaded”. If you would like to shorten it, just go into Options>Aliases and find the alias name and change that to something shorter…

–Mitch

ToggleWireframeShaded.rvb (734 Bytes)

3 Likes

Here is a good place to start

–Mitch

1 Like

Why the F7 keyboard shortcut don’t use a script?

The F7 shortcut uses a macro, the simplest form of scripts. The reason why you can use one key to toggle things on and off is that the command (grid in this case) has options that you can toggle between yes and no.

The SetDisplayMode command that you would need to change from a wireframe to a shaded display mode demands that you change the name of the mode, i.e. not just on / off. You could use two keys to set the mode and use macros. That way you could assign wireframe to Z and shaded to X. '_SetDisplayMode _Wireframe and '_SetDisplayMode _Shaded.

3 Likes