Effect deletion error
Copy link to clipboard
Copied
Hi everyone,
I have two effects on the layer: my effect with index = 1 and another effect (say, 'blur', for example) with index = 0 (higher in the list). I'm trying to delete 'blur' effect on some parameter change. Here is code I use:
static PF_Err UserChangedParam (...) {
...
ERR(suites.PFInterfaceSuite1()->AEGP_GetEffectLayer(in_data->effect_ref, &effect_layerH));
ERR(suites.EffectSuite4()->AEGP_GetLayerEffectByIndex(NULL, effect_layerH, 0, &effectH));
ERR(suites.EffectSuite4()->AEGP_DeleteLayerEffect(effectH));
ERR(suites.EffectSuite4()->AEGP_DisposeEffect(effectH));
...
}
This code deletes effect, but after this I have error window: "invalid index in indexed group".
What's going wrong here?
Thanks,
Ilya
Copy link to clipboard
Copied
Hi Ilya,
I don't think you should dispose of an effect you just deleted.
Try removing your last line, see if it's better.
Cheers,
François
Copy link to clipboard
Copied
in any case, you can't delete a layer effect from another effect on the
same layer. (or add one, for that matter) it messes up the some internal
lists AE uses while in the middle of executing that list.
the only safe way of doing that is by creating an AEGP, letting it know
what effect you wish to delete, and then removing it from the AEGP on idle
time, while none of the layer effects are executing.
On Wed, Mar 22, 2017 at 4:28 AM, françois leroy <forums_noreply@adobe.com>
Copy link to clipboard
Copied
Thanks, Francois and Shachar, for your answers!
To Francois - I tried to remove AEGP_DisposeEffect command but result was the same.
To Shachar - you wrote "the only safe way of doing that is by creating an AEGP". Do you mean creating another additional AEGP plugin for such functionality? Or using AEGP_RegisterIdleHook in my plugin to register function and add/delete effects in this function?
Another additional question - is it better or not to add/delete effects using script and AEGP_ExecuteScript? Or I'll face with the same problems?
Thanks,
Ilya
Copy link to clipboard
Copied
i do it with a separate AEGP plug-in, but i think one of the guy here on
the forum said he tried it with AEGP_RegisterIdleHook on his effec plug-in
and it worked.
Copy link to clipboard
Copied
Hi Ilya and Shachar,
I did use AEGP_RegisterIdleHook in an effect plugin and it worked.
I don't remember exactly, but I think you just need to replace A_Err by PF_Err... You'll have to try.
Cheers,
François
Copy link to clipboard
Copied
Thanks a lot for answers!
I tried and it works both with A_Err and PF_Err. I used AEGP_RegisterIdleHook in GlobalSetup.
But is there any way to send data to IdleHook function (in effect plugin)? For example, in another functions I use the following code to get suites:
AEGP_SuiteHandler suites(in_data->pica_basicP);
but in IdleHook I don't have in_data.
And one more question about IdleHook: is it possible to force rerender from IdleHook function (I'm trying to catch some changes during Idle and rerender on these changes).
Thanks,
Ilya
Copy link to clipboard
Copied
I don't know what kind of data you want to pass...
But for example, if you want to pass a simple number, you could add a hidden parameter, set its value on param change, and check the parameter's value at idle time. If you want to pass more complicated data, well, you can add more parameters...
If you want to re-render, you could also add a hidden paremeter and change its value at idle time, it will trigger a re-render.
Cheers,
François
Copy link to clipboard
Copied
Thanks, François,
And what about pointers, like PF_InData *in_data? Is it possible? I'm stuck with using suites in IdleHook for effect plugin (how to do it without in_data or how to pass in_data to IdleHook)...
Thanks,
Ilya
Copy link to clipboard
Copied
I don't know if you can pass a pointer (I doubt it, but you can try!)...
Can you give more details about what you try to achieve? There must be workarounds to find...
May be you can just delete the effect at idle time and do all the rest during paramChange (this way you have access to the data you need).
Cheers,
François

