Skip to main content
Participating Frequently
June 28, 2023
Question

CEP extension development - How to detect user selection changes in active project

  • June 28, 2023
  • 2 replies
  • 1440 views

I'm developing an After Effects extension using adobe CEP, and as far as I've found so far, there is no built-in way of detecting changes in user selection i.e. - listening to events like user has selected a different composition(s)/layer(s).

Beacause of that, I've created a simple workaround where I set an interval in the CEP side, and each 200ms I issue a call to ExtendScript to fetch the current user selection(by "selection" I mean compositions/layers - if any where selected), and update the panel UI accordingly.

The solution above works nicely for fairly smaller projects, but for projects that contains large amount of compositions and layers, it just crashes After Effects completely.

Is there any official/recommended way of acheiving that goal?

2 replies

Mathias Moehl
Community Expert
Community Expert
June 28, 2023

I think the team from Adobe decided to do not offer these kinds of events for performance reasons. It would be a very bad user experience if with each selection change a ton of installed extensions would do all kinds of operations which might slow down the app. Of course, workarounds like the one you described make this even worse, as they slow down the app not only when selection changes, but all the time.

Hence, the official/recommended way is avoiding this entirely. Let your panel update when it is focused (i.e. when the user clicks on it) or offer an explicit refresh button. I see that having it update instantly seems more elegant, but it is not really feasible, unfortunately.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
saraa32557369
Participating Frequently
June 13, 2025

In Pro Panel sdk there's that function. When you perform an operation the system sho a messagge about the action.

The callback is in premiere.jsx 

projectPanelSelectionChanged : function (eventObj)
 
Why the do Adobe teams this callback if is dangerous ?
 
Justin Taylor-Hyper Brew
Community Expert
Community Expert
June 13, 2025

AE and Premiere Pro have very different API styles. AE could implement this behavior, but they haven't, so the best way with the tools we're provided is to update the UI when the panel is focused in most cases.

Mylenium
Legend
June 28, 2023

I don't think so. Forcing the selection to be checked basically triggers a whole cascade of AEGP and other API operations and causes a redraw and eventually you'll just cause a race condition where AE can't even do it inside your 200 ms and then it's *crash,boom,bang*. Extending the time/ adapting it dynamically may give more breathing room for larger projects, but ultimately you're only postponing the inevitable...

 

Mylenium