Skip to main content
Participating Frequently
Feb 16, 2025 3:55 PM UTC
Answered

Set the mask in AE and use AEGP_GetLayerNumMasks to query the number of masks. The return value is 0

Hello All

I have a question when using c++ to develop AE export plug-in,Set the mask in AE and use AEGP_GetLayerNumMasks to query the number of masks,The return value is 0,The specific code is as follows:

AE Version: 2025

System version: M3 Pro,macOS 15.3
  A_long numMasks = 0;
  RECORD_ERROR(suites.MaskSuite6()->AEGP_GetLayerNumMasks(layerHandle, &numMasks));
  for (int i = 0; i < numMasks; i++) {
    AEGP_MaskRefH maskHandle;
    RECORD_ERROR(suites.MaskSuite6()->AEGP_GetLayerMaskByIndex(layerHandle, i, &maskHandle));
    auto mask = ExportMask(context, maskHandle);
    masks.push_back(mask);
    RECORD_ERROR(suites.MaskSuite6()->AEGP_DisposeMask(maskHandle));
  }

Has anyone encountered similar problems?

shachar carmiCorrect answer
Community Expert
Feb 17, 2025 12:36 PM UTC

Hi,track masking requires two layers (the mask layer and the masked layer).Cannot set mask if there is only one layer


hold on... a track ammte and a mask are two different things...

1. track matte - one layer operating with the alpha/luma of the layer above it.

2. mask - a vector shape drawn on a layer with the pen tool.

if your situation is the same as #1, then the mask suite is the wrong way to go as there are no masks on that layer, and then getting 0 as the num_masks actually makes sense...

9 replies

Community Expert
Feb 17, 2025 5:58 AM UTC

the code looks ok. is the layer handle valid? does AEGP_GetLayerMaskByIndex return some error?

Translate
Participating Frequently
Feb 17, 2025 8:01 AM UTC

hi,The layer can be exported normally, indicating that the layhandle is valid.

Because the return value of AEGP_GetLayerNumMasks is 0, the code will not be executed to the line where AEGP_GetLayerMaskByIndex is located.
If I do not check the number of masks and directly call AEGP_GetLayerMaskByIndex to get the mask with index 0, AE will report the following error
The above error message indicates that the current layer does not have an exportable mask.
But the mask has indeed been set in AEtThe following is the corresponding project file
 Please help answer this question, thanks!
Translate
Community Expert
Feb 17, 2025 8:20 AM UTC

i don't know what the RECORD_ERROR macro is, but it it's similar to ERR then it won't execute the enclosed command if the value of err is not 0. so, what is the value of err before hitting AEGP_GetLayerNumMasks? what's the value of err after?

Translate