Skip to main content
Known Participant
December 11, 2011
Question

How can I detect when my effect is being deleted from a layer?

  • December 11, 2011
  • 3 replies
  • 1464 views

Hi all.

I have an effect plugin and I'd like to run some code when the effect is deleted from a layer. Right now I'm handling PF_Event_CLOSE_CONTEXT, but I'm pretty sure that's the wrong place because that's also called at other times (like when the cusomter selects another layer or closes the project). Since the PF_EventUnion that's passed in for that event is empty, I don't see a way to detect why the event is being fired.

Any ideas how to detect when an effect is deleted? Thanks.

This topic has been closed for replies.

3 replies

Known Participant
December 13, 2011

Sigh. Thanks!

Community Expert
December 13, 2011

i'm glad to hear you worked you way around this problematic problem.

as for SEQUENCE_SETUP:

generally speaking, yes, that is the place to run code from reporting to the AEGP.

sequence_setup is called only once per instance, as it gets applied.

but there's one problem with it.

sometimes this call gets triggered before the instance is "self aware".

what does that mean?

it means that if you try to use GetNewEffectForEffect, or try to get the layer the effect is applied on, you'll either crash or get invalid results.

why?

because AE is expecting you to allocate memory during that call, and it may do so before the effect is associated with a layer.

i'm not always the bad news guy...

:-(

Community Expert
December 11, 2011

hi SirPentor75!

that's actually a tough problem.

ideally, you would do that during the SEQUENCE_SETDOWN call. it's supposed to be called when a certain instance of an effect gets deleted.

however, that call is lingered for as long as the effect is still in the undo stack.

if you don't mind that delay then you have no problem, but if you have to act immediately upon deletion, that's not the solution for you.

there's no perfect solution for immediate notification of deletion.

you could intercept keyboard calls and act when delete of backspace are pressed, but that will only work if you plug-in is the only one selected at that time.

the only solution i can think of is a bit messy.

create an AEGP to which all new instances report their existence. now on idle time you can scan the project and look for them. this way when an instance is missing, you can run your code. (but you won't be able to access any of the data of the missing instance)

i hope this of this helps.

(though it's mostly bad news)

Known Participant
December 12, 2011

Thank you very much for the information, Shachar. Obviously that isn't what I wanted to hear, but it is very helpful!