Skip to main content
Participating Frequently
June 11, 2024
解決済み

I'm new to the AE SDK and want to know how to get the name of the selected layer. Thank you very muc

  • June 11, 2024
  • 返信数 1.
  • 832 ビュー

Hi, I'm just getting started with the AE SDK and learning how to make plugins, but the first problem I'm having is how to get the name of the selected layer in the AE project. I've tried. A lot of things. It's all wrong. Can help write a simple code, I refer to. Is that OK? Thank you very much. I am currently using the 2020 version of SDK

このトピックへの返信は締め切られました。
解決に役立った回答 shachar carmi

you traverse the collection using AEGP_GetCollectionItemByIndex(). for each such call, you get a AEGP_CollectionItemV2 for that collection item. this is that structure:

typedef struct {
AEGP_CollectionItemType type;
// the union is not used for AEGP_CollectionItemType_STREAMREF
union {
AEGP_LayerCollectionItem layer;
AEGP_MaskCollectionItem mask;
AEGP_EffectCollectionItem effect;
AEGP_StreamCollectionItem stream;
AEGP_MaskVertexCollectionItem mask_vertex;
AEGP_KeyframeCollectionItem keyframe;
} u;


AEGP_StreamRefH stream_refH; // valid for all types
} AEGP_CollectionItemV2;

 

you can tell what that item is by the value of the "type" var. if it's a layer type, the value in the "layer" var will be a valid AEGP_LayerH.

 

返信数 1

Community Expert
June 11, 2024

start off with AEGP_GetNewCollectionFromCompSelection(). then traverse the collection using AEGP_GetCollectionNumItems() and AEGP_GetCollectionItemByIndex().

now that you've got the currently selected layer (there may be more than one selected...), use AEGP_GetLayerName().

Participating Frequently
June 14, 2024

Hello, thank you very much for your answer, but I have a question. I used the function AEGP_GetCollectionItemByIndex to obtain the parameter AEGP_CollectionItem. Then I use AEGP_GetLayerName to get the name of the layer, but I find that AEGP_GetLayerName needs to be passed in AEGP_LayerH. So how can AEGP_LayerH be obtained? Thank you very much for your reply

shachar carmiCommunity Expert解決!
Community Expert
June 14, 2024

you traverse the collection using AEGP_GetCollectionItemByIndex(). for each such call, you get a AEGP_CollectionItemV2 for that collection item. this is that structure:

typedef struct {
AEGP_CollectionItemType type;
// the union is not used for AEGP_CollectionItemType_STREAMREF
union {
AEGP_LayerCollectionItem layer;
AEGP_MaskCollectionItem mask;
AEGP_EffectCollectionItem effect;
AEGP_StreamCollectionItem stream;
AEGP_MaskVertexCollectionItem mask_vertex;
AEGP_KeyframeCollectionItem keyframe;
} u;


AEGP_StreamRefH stream_refH; // valid for all types
} AEGP_CollectionItemV2;

 

you can tell what that item is by the value of the "type" var. if it's a layer type, the value in the "layer" var will be a valid AEGP_LayerH.