I’m trying to understand how to make a Python script that would run once a second. Was trying to do it with a modal operator, but for some reason it’s not giving the expected result:
time.time() returns seconds.milliseconds same as time.clock() , just they have different start times
( time.time starts from 00:00:00 UTC, while time.clock starts from when it was first run ).
EDIT: Ok, it looks like Blender doesn’t output the printed value unless the mouse is constantly moving over top the Blender window while it’s running. How odd…I think this might be due to some sort of underlying performance optimization, but I’m not sure if it’s just waiting to show the results, or actually running the operation multiple times in a row to catch up when the mouse moves…
As far as I understand it (and I could be totally wrong) modal (“def modal(self, context, event):”) is only executed if an event happened. That can be a mouse move, click, key stroke, … This also means that if nothing happens, your script will keep “RUNNING_MODAL” and wait for the next event to happen before modal is executed again. This may explain what is happening.
I think that an event_timer might be what you are looking for. Blender comes with an example for that (operator_modal_timer.py). You can find it in the Text Editor’s ‘Templates’ menu.