Blender 2.58 events list

I read that the Python API for Blender events would be complete by 2.58, can someone point me to the list of supported events? I could not find it here:

http://www.blender.org/documentation/blender_python_api_2_58_release/contents.html

Is the frame_change event supported at last?

Thanks

But those are workarounds for 2.57 littleneo, I thought this was resolved in 2.58?

as far as I know (still hardly testing bpy, still a bit lost…) frame change event can be handled with a modal operator, but it won’t react during an animation render (there’s no render context says Atom). so if you need to check for frame change during render to do somthing, you need the Atom’s script.

Ok, I did some further testing on the modal timer approach and it does seem to work just fine. It worked with Blender Internal renderer and Yafaray renderer for GUI playback and render. It also provides a valid context during the event. I did not do a lot of testing yet. One thing I do notice is that it does gobble about 10-20% of my CPU just to run. Dang! My threaded approach in CameraPlus was only taking about 1-2% with the same timer interval. I also discovered that if you accidentally run the code again while it is already running you crash Blender. Also if you do modification within the event that alter the state of the dependency graph you may end up with a crashed Blender as well.

I think, overall, this may be a better approach to frameChange processing because it does seem to work with multiple renderers. This is always very important to me, if you can’t render you animation, whats the point? So I think the next step is to try and port a previous AddOn to this approach and see if it holds up to heavier code processing within the event.


# Example showing how to use a timer to emulate a frame change event.
import bpy

class ModalTimerOperator(bpy.types.Operator):
    '''Operator which runs its self from a timer.'''
    bl_idname = "wm.modal_timer_operator"
    bl_label = "Modal Timer Operator"

    _timer = None
    last_frame = 0
    color_S = 0.0
    color_H = 0.0
    
    def modal(self, context, event):
        if event.type == 'ESC':
            # Restore GUI color before canceling.
            color = context.user_preferences.themes[0].view_3d.back
            color.s = self.color_S
            color.h = self.color_H
            return self.cancel(context)

        if event.type == 'TIMER':
            # Change theme color to visually show that I am running.
            color = context.user_preferences.themes[0].view_3d.back
            color.s = 1.0
            color.h += 0.01
            
            frame_current = context.scene.frame_current
            if frame_current != self.last_frame:
                # Put your frame change code here.
                # Simple example moves default cube.
                ob = bpy.data.objects["Cube"]
                if bpy.context.scene.frame_current == 1:
                    ob.location.y = 0
                else:
                    ob.location.y = ob.location.y+1
                    
                # End your code.                
                self.last_frame = frame_current
            else:
                # Same frame, I don't need to update.
                pass

        return {'PASS_THROUGH'}

    def execute(self, context):
        color = context.user_preferences.themes[0].view_3d.back
        self.color_S = color.s
        self.color_H = color.h
        context.window_manager.modal_handler_add(self)
        self.last_frame = context.scene.frame_current
        self._timer = context.window_manager.event_timer_add(0.3, context.window)
        return {'RUNNING_MODAL'}

    def cancel(self, context):
        context.window_manager.event_timer_remove(self._timer)
        return {'CANCELLED'}


def register():
    bpy.utils.register_class(ModalTimerOperator)


def unregister():
    bpy.utils.unregister_class(ModalTimerOperator)


if __name__ == "__main__":
    register()

    # test call
    bpy.ops.wm.modal_timer_operator()

I love that pure bpy one. the previous ‘threaded’ script (threading module) was crashing in my script. you really should publish that as a versatile addon.

So is there a list of supported events somewhere or not? :slight_smile:

I started experiencing crashes using the above timer technique when I try to set and change the active object. It only occurs when rendering an animation. I could only get 5-15 frames using this technique. So it depends upon what you do inside the timer event. Just moving an object seems to work fine.

I have not seen a list of supported events. There is the new event system for updating when a parameter changes. But it seems the frame change is still left blowing in the wind.

I was looking at 2.6 feature list and thought surely they would make an attempt or mention it but I saw nothing to indicate progress in that direction.

I get the impression that 70-80% of Blender users just model and never touch python. Of us small percentage of python scripters an even smaller percentage have a need for events.

So I guess the Vulcan credo applies here. The needs of the many outweigh the needs of the few or the one.