Wow:
PF_Err get_layer_handle(PF_InData *in_data, AEGP_LayerH *layer_handle)
{
AEGP_SuiteHandler suites(in_data->pica_basicP);
PF_Err err = PF_Err_NONE;
AEGP_EffectRefH effect_handle = NULL;
ERR(suites.PFInterfaceSuite1()->AEGP_GetNewEffectForEffect(plugin_id, in_data->effect_ref, &effect_handle));
AEGP_StreamRefH stream_handle = NULL;
ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(CG_FRAME_DATA_LAYER, effect_handle, CG_FRAME_DATA_LAYER, &stream_handle));
AEGP_LayerIDVal layer_id;
{
// Layer effects can't be keyframed, so the timestamp doesn't matter.
A_Time timeT = {0,1};
AEGP_StreamValue value;
ERR(suites.StreamSuite2()->AEGP_GetNewStreamValue(plugin_id, stream_handle, AEGP_LTimeMode_LayerTime, &timeT, TRUE, &value));
layer_id = value.val.layer_id;
ERR(suites.StreamSuite2()->AEGP_DisposeStreamValue(&value));
}
AEGP_LayerH effect_layer_handle = NULL;
ERR(suites.PFInterfaceSuite1()->AEGP_GetEffectLayer(in_data->effect_ref, &effect_layer_handle));
AEGP_CompH comp_handle = NULL;
ERR(suites.LayerSuite5()->AEGP_GetLayerParentComp(effect_layer_handle, &comp_handle));
ERR(suites.LayerSuite8()->AEGP_GetLayerFromLayerID(comp_handle, layer_id, layer_handle));
if(effect_handle != NULL)
ERR(suites.EffectSuite2()->AEGP_DisposeEffect(effect_handle));
return err;
}
I hope there's a simpler way to do something this basic. The SDK documentation needs a major overhaul; I was only able to get this to work by combining several of the (not very cleanly-written) examples and a huge amount of web searching.