ZoomToggle plugin

As a result of a wish by Dan Bayn about providing WorkNC-like temporary zooming I wrote the following plugin:
ToggleZoom.zip (3.2 KB)

It doesn’t actually do what was asked for, but the way to use it is to install the plugin and put the command ToggleZoom into the middle mouse button macro:

Middle click anywhere in the viewport and the camera zooms in, click again anywhere within the same viewport and the camera zooms out again. Zooming happens by adjusting the lens-length in perspective viewports and by changing the camera position in parallel viewports. The ToggleZoom command can of course also be run through the command line, but it will only work if the cursor is over the currently active viewport.

The zoom factor to use can be adjusted using the ToggleZoomFactor command.

David, I see the command does not repeat on Enter or Right click - (i.e. zoom back out) Is that by design?

-Pascal

Assigning it to a Function key (F3 for example) makes this really easy to use.

Yes, the command does not repeat, does not undo, and is usable from within other commands. Specifically because I thought that it would run inside other commands, repeatability seemed like a bad idea.