← All ideas
  • Published 11 Jul 2023

Add handlers for Scene and Workspace change

Hello!

Few years ago Pablo Dobarro made a blogpost about asset-centric workflow as he had see it in Blender. As far as I remember the main idea behind it was a workspace-based workflow: workspace represents a certain task with one you can associate tools you need only for that task.

In this paradigma workspaces are not just an areas layout, but a way the data flows in a pipeline.

Anyway, developing an addon for previz work I try to bind together next pipeline steps: Storyboarding, Animatics, Layout, Editing, in a one streamlined seamless workflow . The best solution I could designed for the addon is workspace switch which rhymes with Pablo's vision in some way.

In the end of a day I made some success, because I can associate a scene with a workspace, so prototype is working. But what I can't handle in an easy way is refreshing and rebinding data related to different stages. depth_graph_update handler could help, but I haven't tried it on a constant base, since I am aware of its resource-consuming nature.

Maybe I'm not right - I'm not a hardcore developer. But seems it has a callback that runs every single change, even selecting an object, that obviously I do not need. I need to store the data once I switch workspace or scene. And so with refreshing stored data - just once.

What could make my life easier and I think could provide a new way of workflow for artists and new posibilities for devs are workspace_change and scene_change handlers. And since we got few updates in handlers API in a recent time, maybe we can get such handlers soon.

So it could look like:

bpy.app.handlers.workspace_change_pre

bpy.app.handlers.workspace_change_post

bpy.app.handlers.scene_change_pre

bpy.app.handlers.scene_change_post

100%

Development Status: Open

Upvote 3 Downvote 0
sickmonkeydub
11 Jul 2023

3 Comments

Richard-Brenick

Hi there :)

This seemed like a very reasonable request, and as I'm trying to get familiar with blender source code, I decided to take a stab at it.

Have opened a pull request here: projects.blender.org/blender/blender/pulls/110150

If it doesn't get merged, I recommend the 2022 Blender conference talk "Beginning developer workshop", as Application Handler are used as the first example (Since they're only a couple of lines to add): youtube.com/watch

1
sickmonkeydub Author

Hi, Richard!

Glad this proposal got attention!

Since I did a proposal I'd found bpy.msgbus . It works pretty much like "post-handler" for almost any blender property. Sometimes kinda tricky to setup, but works in many cases. For scenes and workspaces too.

But it doesn't help with pre-change stuff, which is pretty much needed... I hope your request will make it in near future. Thanks a lot for your work and your indifference!

And thanks for pointing at that talk. I'll defenetly look at it.

I think rather than more handlers, they should just get the depsgraph handler to return the details of the object and attribute that triggered the depsgraph update. That way you could have one handler in which you can then call an unlimited number of your own functions based on what triggered the update.