Highlighted

Get effect index in layer (opposite of AEGP_GetLayerEffectByIndex)

Participant ,
Jul 04, 2020

Copy link to clipboard

Copied

I am trying to get the index of an effect on a layer, rather like an opposite of EFFECTSUITE4()->AEGP_GetLayerEffectByIndex, which 'Retrieves (by index) a reference to an effect applied to the
layer'.

 

There's no built-in function, so I tried to roll my own by getting AEGP_GetLayerNumEffects, and then EffectSuite4()->AEGP_GetLayerEffectByIndex for each, but as far as I can tell, there's no useful way to compare AEGP_EffectRefHs, either. 

 

Is there any way to do either of these things (get the index of the effect directly, or to compare EffectRefHs)?

 

 

 

 

Adobe Community Professional
Correct answer by shachar carmi | Adobe Community Professional

get the stream ref of the first effect param, and use AEGP_GetNewParentStreamRef to get the effect's stream representation.

then use AEGP_GetStreamIndexInParent to get the effect index on the layer.

TOPICS
SDK

Views

171

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Get effect index in layer (opposite of AEGP_GetLayerEffectByIndex)

Participant ,
Jul 04, 2020

Copy link to clipboard

Copied

I am trying to get the index of an effect on a layer, rather like an opposite of EFFECTSUITE4()->AEGP_GetLayerEffectByIndex, which 'Retrieves (by index) a reference to an effect applied to the
layer'.

 

There's no built-in function, so I tried to roll my own by getting AEGP_GetLayerNumEffects, and then EffectSuite4()->AEGP_GetLayerEffectByIndex for each, but as far as I can tell, there's no useful way to compare AEGP_EffectRefHs, either. 

 

Is there any way to do either of these things (get the index of the effect directly, or to compare EffectRefHs)?

 

 

 

 

Adobe Community Professional
Correct answer by shachar carmi | Adobe Community Professional

get the stream ref of the first effect param, and use AEGP_GetNewParentStreamRef to get the effect's stream representation.

then use AEGP_GetStreamIndexInParent to get the effect index on the layer.

TOPICS
SDK

Views

172

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 04, 2020 0
Adobe Community Professional ,
Jul 04, 2020

Copy link to clipboard

Copied

get the stream ref of the first effect param, and use AEGP_GetNewParentStreamRef to get the effect's stream representation.

then use AEGP_GetStreamIndexInParent to get the effect index on the layer.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 04, 2020 1
Participant ,
Jul 04, 2020

Copy link to clipboard

Copied

It works! Perfectly! Genius! Thank you! 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 04, 2020 0
Participant ,
Jul 04, 2020

Copy link to clipboard

Copied

Hi again, Shachar.

 

I'm using your method as follows: 

 

PFInterfaceSuite1()->AEGP_GetNewEffectForEffect 

StreamSuite5()->AEGP_GetNewEffectStreamByIndex

DynamicStreamSuite4()->AEGP_GetNewParentStreamRef

DynamicStreamSuite4()->AEGP_GetStreamIndexInParent

 

This works great except one use-case I'm interested in -- in the UI thread of PF_Cmd_SEQUENCE_RESETUP, when I have duplicated a layer with the effect plugin. 

 

In that case, I get the non-fatal error dialog: "After Effects error: internal verification failure, sorry! {child not found in parent} 29::0"

 

The problem seems to be caused by AEGP_GetNewEffectForEffect. Presumably, the effect has not been fully instantiated yet. 

 

I don't need the info in the case of a duplicated instance of the plugin, but I do need to know the info if it's not a duplication. 

 

Do you know of any way to anticipate the error, or at the least to get a NULL AEGP_EffectRefH, so I can skip the function? 

 

Cheers. B. 

 

 

 

 

 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 04, 2020 0
Adobe Community Professional ,
Jul 04, 2020

Copy link to clipboard

Copied

the problem is that during sequence_setup (and some other rare cases as you have noted) the new effect instance is not yet associated with a layer. you should put a flag in your sequence data struct noting "data is new and needs updating" which is on by default, and populate sequence data on the first chance where you get a valid EffectRef.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 04, 2020 0
Participant ,
Jul 04, 2020

Copy link to clipboard

Copied

Thanks Shachar... How can I check whether or not the EffectRef is valid? Creating the effect Ref (AEGP_GetNewEffectForEffect) seems to cause an error. Is there another way to create it, so I can check if it's NULL? 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 04, 2020 0
Adobe Community Professional ,
Jul 04, 2020

Copy link to clipboard

Copied

you're right. i checked on my end, and i completely avoid calling AEGP_GetNewEffectForEffect on these calls:

1. sequence setup.

2. sequence resetup.

3. new context UI event.

 

in all these, the effect instance may not yet be associated with a layer, or may not have the association you'd expect (as in the case of resetup during a duplication, where the acting instance is actually the original one and not the new one).

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 04, 2020 0
Participant ,
Jul 04, 2020

Copy link to clipboard

Copied

Is there a way to check the status of an instance some other way? 

 

All of this is an still an attempt to work around the bug with FORCE_RERENDER (which creates a phantom undo, which if undone unsyncs the UI & render threads) from a year ago.

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 04, 2020 0
Participant ,
Jul 05, 2020

Copy link to clipboard

Copied

Apparently I can get a valid EffectRef, if I know the index of the effect on the layer (AEGP_GetLayerEffectByIndex). But I can't get the index unless I have a valid EffectRef. 

 

My life! 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 05, 2020 0