Extensions:2.6/Py/Scripts/System/ScriptEvents

提供: wiki
< Extensions:2.6‎ | Py‎ | Scripts‎ | System
移動先: 案内検索
Script Events
a versatile modal operator, an event logger, and a popup report to share with other addons.
UI location Group: System
Usage ops.wm.modal / context.window_manager.modal / ToolShelf : modal config, modal start, modal stop, modal status, modal report
Version 0,1 Author(s) Littleneo
Blender 2.58 r#37702 License GPL


Executable information
File name script_events init file.
Current version download http://projects.blender.org/tracker/download.php/153/467/28022/17150/script_events_v02.zip
Python modules time


Warning Should work on Mac and nux ?

Usage, Feature

this addon can be used to catch keys or mouse events, to trigger a function during a frame change or an animation render, to run scheduled functions etc.. this is an embedded and more reliable version of the modal templates bundled with blender. more reliable because it takes care for you of the tricky part and avoid to have more than one instance to run at a time. also, any change to the configuration will apply immediately even if the operator is already running:

  • change the function calls to the hud and the modal function,
  • enable/disable the event timer or the hud,
  • change the timer latency,

can be done while running.

the addon also provides some log facilities, with timestamp, errorlevel and blender runtime.

Installation

  • Download the script then unzip it into your /scripts/addons folder.
  • Open Blender and go to the addons tab in User Preferences.
  • Select the System category and enable Script Events.

Instructions

The modal operator can be configured and managed from the user interface and from your code.


from the toolshelf

ui has not been attached to the blender ui to remain silent while your script use it. but a popup interface and some common operators are available from the toolshelf :

Script events1.pngScript events3.png

  • the first checkbox is used to start or stop the modal,
  • the first text field modal_example is the name of the function that will be executed by the modal,
  • the timer checkbox instructs wether to add an event timer or not. interval is the timer latency,
  • the hud chekbox enable or disable a hud in the viewport. here, default_hud is the name of the hud function (the bgl code),
  • quiet enable or disable the popup report,
  • debug displays various info about the addon life.
  • the last button on the left will restore the modal default values
  • the two other buttons display or hide the console and reports the last events in the console

Script events2.png


from python

bpy.ops.wm.modal_start()

bpy.ops.wm.modal_stop()

bpy.context.window_manager.modal.status = True

bpy.context.window_manager.modal.timer = True

bpy.context.window_manager.modal.timer_refresh = 0.2

bpy.context.window_manager.modal.hud = False

bpy.context.window_manager.modal.func = 'myModalFunc(self,context,spam)'

Support