I have a good use case for addon architecture with as much inheritance as possible but with wide override possibility.
We are currently working on implementing Stax for Ayon. It is a an Application Template of Blender, it uses Blender as an engine but reshapes all the native UI to propose a different UX.
Hence, I’d like to create an addon which would rely as much as possible on the Ayon’s Blender addon with some overrides to avoid rewriting it all, such as the launch context.
The first step is to be able to start Stax from any folder selected and not only from a task, is there a way to override something like is_compatible from a host implementation? It’d look like:
def is_compatible(self, selection):
if selection.is_folder_selected:
# If folder is of a type related to an episode
return selection.get_folder_entity()['folderType'] in ["Episode", "Sequence", "Shot"]
else:
return False
Our current approach is to use a LauncherAction but it requires to start a blender process on our own, which doesn’t benefit from any Ayon code (like launch hooks).
Could ApplicationManager be relevant for such use?
Once Blender has been launched, we’ll need to hook (PostLaunchHook) to load reviewable products into Stax’s timeline (Blender’s Video Sequencer) from the context. For example an episode would load all the reviewable products from shots of the episode. To maximize code mutualization it’d be best we rely on Ayon’s Blender loader plugins.
To sum steps up:
Launch Blender from specific folder (not task only) with Ayon’s implementation but with the possibility to override the launch context to start with Stax App Template
Add a post launch hook to use an Ayon Blender addon plugin loader for loading a bunch of reviewable products.
Any idea of what the addon’s architecture should look like? Thanks!
That is my current lead. But to do so I have to deal with the second part of my technical issue: how to start Blender bypassing context but still using as much AYON’s blender addon code (events and loaders in my case) as possible?
Thanks for DJV, I’ve looked at it and it is interesting but the implementation is very small and works only with one representation at a time, when Stax is meant to deal with big timelines.
As far as I know, the best thing that suits your description is:
Have stax addon
Add stax to supported applications
Either:
a. (work regularly as we do in UE) create a dedicated task for it + implement a button to populate your workfile with the latest reviews.
b. OR Add a folder action that opens a session with the latest reviews within that folder.
One solution I’m thinking about, is creating a task “review” for every episode, sequence or shot folders. I cannot find a way to create a task for folders in the ayon server UI, how am I supposed to proceed?
EDIT : I proposed to Allow to launch an app with custom arguments but the appropriate way is to do it with a PreLaunchHook using self.launch_context.launch_args.extend(["my", "args"])