What's the best strategy for having custom props on bpy_structs that don't subclass ID?

I made a simple python script that mimics the zbrush split-screen allowing to synchronize the location/rotation/zoom of two view3ds (focused on different objects). While trying to turn it into a proper plugin I got stuck with not being able to specifically identify the areas.

The closest I was able to get is Screen which has several areas of interest. Now, for every view3d area I want to store two custom properties: is it a leader view, a follower view or a non-managed view, and the object that this view focuses on.

Here are the ideas I had:

  1. use custom props. A no-go as Area doesn’t subclass ID and can’t have those
  2. use python props on Area. Pretty useless as you can’t expose those to the UI so you can’t edit them in a user-friendly way
  3. store the context in a list on the closest ID (Screen). That could theoretically work but I found no way to make sure the user’s changing of areas could be properly tracked to update my collection (other than to make a custom python prop on the area and verify those on every update).

Are there any better strategies that I’m missing?

TL;DR: I need to store a bool property and a pointer property per-Area and expose those to the UI.

2 Likes