Changeset View
Changeset View
Standalone View
Standalone View
doc/python_api/examples/bpy.app.timers.3.py
| """ | """ | ||||
| Run a Function n times every x seconds | Run a Function n times every x seconds | ||||
| -------------------------------------- | -------------------------------------- | ||||
| """ | """ | ||||
| import bpy | import bpy | ||||
| counter = 0 | counter = 0 | ||||
| def run_10_times(): | def run_10_times(): | ||||
| global counter | global counter | ||||
| counter += 1 | counter += 1 | ||||
| print(counter) | print(counter) | ||||
| if counter == 10: | if counter == 10: | ||||
| return None | return None | ||||
| return 0.1 | return 0.1 | ||||
| bpy.app.timers.register(run_10_times) | bpy.app.timers.register(run_10_times) | ||||