Copy link to clipboard
Copied
Hi,
The objective is to identify and select a certain effect instance among all instanciated effects. I'm using the following code segment to iterate and scan all the effects currently applied:
// Data structure used for identification
typedef struct
{
uint64_t uniqueID;
bool isKeyEffect;
}
t_struct;
...
AEGP_ItemH itemH2 = 0;
AEGP_CompH compH = 0;
err = suites.ItemSuite8()->AEGP_GetActiveItem(&itemH2);
if(itemH2 == 0)
return err;
err = suites.CompSuite9()->AEGP_GetCompFromItem(itemH2, &compH);
if(compH == 0)
return err;
AEGP_Collection2H collectionH = 0;
AEGP_LayerH layerH = 0;
A_long numLayers = 0;
t_struct key =
{
getEffectID(),
false
};
bool found = false;
if(AEGP_GetCompNumLayers(compH, &numLayers) == PF_Err_NONE)
{
// Scan comp layers
for(A_long i = 0; i<numLayers; i++)
{
suites.LayerSuite7()->AEGP_GetCompLayerByIndex(compH, i, &layerH);
AEGP_EffectRefH layerEffH;
A_Time t = {};
A_long numEffects;
if(suites.EffectSuite3()->AEGP_GetLayerNumEffects(layerH, &numEffects) == PF_Err_NONE)
{
// Scan all instanciated effects
for(A_long j = 0; j<numEffects; j++)
{
suites.EffectSuite3()->AEGP_GetLayerEffectByIndex(0, layerH, j, &layerEffH);
AEGP_InstalledEffectKey keyH;
suites.EffectSuite3()->AEGP_GetInstalledKeyFromLayerEffect(layerEffH, &keyH);
//// This one is the problem: It never triggers any PF_Cmd_COMPLETELY_GENERAL event.
//// It returns PF_Err_NONE, however.
err = suites.EffectSuite3()->AEGP_EffectCallGeneric(0, layerEffH, &t, PF_Cmd_COMPLETELY_GENERAL, (void*) &key);
////
if(key.isKeyEffect)
{
// Select effect
...
found = true;
}
suites.EffectSuite1()->AEGP_DisposeEffect(layerEffH);
if(found)
break;
}
}
}
}
getEffectID() returns a unique 64 bits identifier generated when my effect is instanciated.
Now in my event handler I try to do the following to identify my "key" instance:
switch(cmd)
{
case PF_Cmd_COMPLETELY_GENERAL:
{
// Identify effect
t_struct *ptr = (t_struct*) extra;
ptr->isKeyEffect = (ptr->uniqueID == getEffectID());
}
break;
...
}
The problem is that on Mac AEGP_EffectCallGeneric() doesn't trigger any PF_Cmd_COMPLETELY_GENERAL event, while it does on Windows. Any hint on what I am doing wrong here?
Thanks!
Best,
Reimund
AEGP_SetStreamName()
Copy link to clipboard
Copied
well... AEGP_EffectCallGeneric() is a bit strange.
in my experience you can't call AEGP_EffectCallGeneric from a certain
effect to an effect of the same type. for example, a "Gaussian blur" effect
can't call AEGP_EffectCallGeneric to another instance of "Gaussian blur".
if that is the case in your plug-in, then perhaps you should create a
separate AEGP that would handle these calls during idle process.
i did try "bouncing" the AEGP_EffectCallGeneric call through a separate
AEGP via a custom suite, alas if the call chain originates from an effect
and the target is an effect of the same type, it wouldn't work.
Copy link to clipboard
Copied
Hi Shachar,
Thanks for your swift response. That's a bummer as creating a separate AEGP for this type of task seems a little like overkill, doesn't it?
Is there any other simple way for an effect to identify itself, e.g. given an AEGP effect handle (AEGP_EffectRefH) is there a way to access the underlying effect's sequence data handle?
Thanks!
Best,
Reimund
Copy link to clipboard
Copied
only an effect instance has access to it's sequence data handle, and only
when AE passes that handle to the instance. AE may move that memory chunk
between calls.
telling a specific instance by some id is VERY tricky. i personally use a
similar mechanism as you, and i do use AEGP_EffectCallGeneric exactly for
that. i just set up my system in a way where a plug-in need the sequence
data of other instances of his own kind.
as for shipping an extra AEGP just for that task, i don't see it as an
overkill. the user runs an installer. he couldn't care less is it's just 1
file written to the install folder or 100.
i don't know what your instance identification needs are, but perhaps you
can use a different solution. for example, if the identification doesn't
need to survive a project save/load, then you can change some hidden
param's name to be the identifier (it can be done without creating n undo
entry), and that param's name can be read directly by other effects via the
stream suite. just throwing an idea out there.
Copy link to clipboard
Copied
I think the latter would work. Can you give me a hint on how to access another effect's parameter names via the stream suite though?
Thanks!
Copy link to clipboard
Copied
get the effect ref and stream ref as you normally would,
then AEGP_GetStreamName() would do the trick.
On Fri, Aug 3, 2018 at 10:28 PM, reimundd1593001 <forums_noreply@adobe.com>
Copy link to clipboard
Copied
Okay, I see. What would be the correct way to change the parameter name then (I mean AFTER an effect has been instanciated)?
Copy link to clipboard
Copied
AEGP_SetStreamName()
Copy link to clipboard
Copied
Thanks shachar!
I was a little puzzled by the "Only valid for children of AEGP_StreamGroupingType_INDEXED_GROUP" comment in the SDK doc, but it seems like it works just fine.