This script runs function twice without asking!

Hi All.

I’ve written a script which can be found here

This script is a front end for functionality which I hope will eventually be used with the Cycles rendering engine, because it allows for custom views without the need of a camera, and to browse those views.

To use the addon, copy the text into a file and save as .py and import into blender and enable

In the 3D view, look in the Properties (N) panel for the new panel.

Click the ‘add view’ icon to add a new view… add at least 4 views in this way.

CLick the ‘record history’ button. This will assign the following to your blender session :

F5 key -> goto previous view
F6 Key -> goto next view

The problem I have is the following… when I Hit F5, the gotopreviousview function runs twice.

It runs twice no matter what i try, so it basically skips a view everytime. Can anyone help me in this regard as to how to get it to only run once?
If you have any questions on using this addon just post here

Thank you very much in advance:yes:

Oh yes… I know it looks like I’m duplicating functionality from the existing 3D view navigation addon, but it’s just for my testing purposes… :slight_smile:

Anyone know anything about this?

I found the answer!!! Finally!

if event.type == 'F5':
            if event.value == 'PRESS':

This is exactly why the operator was running twice. The key was pressed, but it was also being released, which means that on key press and key release the operator was running. Using the second statement solved the problem.

Wow now I can sleep at night again :smiley:

Not that all the replies posted here will benefit from it… oh well… guess sometimes a man’s left to his own devices