Skip to main content
Participating Frequently
July 5, 2024
Question

About getting key frame values

  • July 5, 2024
  • 1 reply
  • 601 views

Hello, I would like to ask a question, that is, in the development of AE SDK plug-in, how to get the value of the key frame selected by the mouse. I checked the SDK documentation and AEGP_GetNewStreamValue () seemed to work, but when I ran it, it showed no current constext. I don't know what the problem is. Or is there a similar case? Let me learn from it. Thank you very much

This topic has been closed for replies.

1 reply

Community Expert
July 5, 2024

there are two steps here.

1. tell which keyframe is selected. for that, look into "collections". these are arrays of selected items.

2. get the keyframe value. for that, use AEGP_GetNewKeyframeValue().

Participating Frequently
July 7, 2024

Hello, just a few minutes of your time. Is that what it says? After I wrote it this way, when I run AEGP_GetNewKeyframeValue inside AE it says: no current context. the Description Failed to obtain the key frame value is then displayed. Here is the code I wrote, I don't know whether it is correct or not. Could you take a look for me, please? Thank you very much.

 

A_Err PanelatorUI_Plat::GetKeyframe() {
A_Err err = A_Err_NONE;
AEGP_CompH compH = NULL;
AEGP_ItemH activeItemH = NULL;
AEGP_SuiteHandler i_sp = sP;
AEGP_Collection2H collectionPH = NULL;
A_u_long num_itemsPL = 0;

if (plugin_id == 0) {
MessageBox(NULL, "Plugin ID is not initialized", "Error", MB_OK);
return A_Err_GENERIC;
}

if (i_sp.ItemSuite1() == NULL) {
return A_Err_GENERIC;
}

err = i_sp.ItemSuite1()->AEGP_GetActiveItem(&activeItemH);

if (err == A_Err_NONE && activeItemH != NULL) {
AEGP_ItemType itemType;
err = i_sp.ItemSuite1()->AEGP_GetItemType(activeItemH, &itemType);
if (err != A_Err_NONE) {
return err;
}

if (err == A_Err_NONE && itemType == AEGP_ItemType_COMP) {
err = i_sp.CompSuite9()->AEGP_GetCompFromItem(activeItemH, &compH);
if (err != A_Err_NONE) {
return err;
}
}
else {
return A_Err_GENERIC;
}
}
else {
return A_Err_GENERIC;
}

if (err == A_Err_NONE && compH != NULL) {
err = i_sp.CompSuite10()->AEGP_GetNewCollectionFromCompSelection(NULL, compH, &collectionPH);
if (err != A_Err_NONE) {
return err;
}

if (err == A_Err_NONE) {
err = i_sp.CollectionSuite2()->AEGP_GetCollectionNumItems(collectionPH, &num_itemsPL);
if (err != A_Err_NONE) {
return err;
}
}

if (err == A_Err_NONE) {
for (A_u_long i = 0; i < num_itemsPL && err == A_Err_NONE; ++i) {
AEGP_LayerH layerH = NULL;
AEGP_CollectionItemV2 collection_itemP;

err = i_sp.CollectionSuite2()->AEGP_GetCollectionItemByIndex(collectionPH, i, &collection_itemP);
if (err != A_Err_NONE) {
break;
}

if (err == A_Err_NONE && collection_itemP.type == AEGP_CollectionItemType_LAYER) {
AEGP_LayerCollectionItem layerCollectionItem = collection_itemP.u.layer;
layerH = layerCollectionItem.layerH;

if (layerH != NULL) {
AEGP_StreamRefH streamH = nullptr;

err = i_sp.StreamSuite4()->AEGP_GetNewLayerStream(NULL, layerH, AEGP_LayerStream_POSITION, &streamH);

A_long keyframe_count = 0;
err = i_sp.KeyframeSuite3()->AEGP_GetStreamNumKFs(streamH, &keyframe_count);

A_short num_dimensions = 0;
err = i_sp.KeyframeSuite3()->AEGP_GetStreamTemporalDimensionality(streamH, &num_dimensions);

AEGP_StreamType stream_type;
err = i_sp.StreamSuite5()->AEGP_GetStreamType(streamH, &stream_type);
if (err == A_Err_NONE && stream_type == AEGP_LayerStream_POSITION) {
for (A_long j = 0; j < keyframe_count; ++j) {
A_Time keyframe_time = { 0, 1 };

err = i_sp.KeyframeSuite3()->AEGP_GetKeyframeTime(streamH, j, AEGP_LTimeMode_LayerTime, &keyframe_time);

AEGP_StreamValue value;
AEFX_CLR_STRUCT(value);
err = i_sp.KeyframeSuite3()->AEGP_GetNewKeyframeValue(plugin_id, streamH, j, &value);

if (err != A_Err_NONE) {
MessageBox(NULL, "Description Failed to obtain the key frame value", "Info", MB_OK);
return err;
}

ERR(i_sp.StreamSuite2()->AEGP_DisposeStreamValue(&value));
}
}
ERR(i_sp.StreamSuite4()->AEGP_DisposeStream(streamH));
}
}
}
}
}
return err;
}

Community Expert
July 7, 2024

it's hard to tell because the error codes are not check in the few calls before AEGP_GetNewKeyframeValue. please run through the debugger and watch step by step if an err is gotten somewhere. it's most likely you're arriving at AEGP_GetNewKeyframeValue with a bad StreamRef.