• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Problem with AEGP_GetLayerNumEffects and AEGP_GetEffectMatchName

Engaged ,
Feb 08, 2024 Feb 08, 2024

Copy link to clipboard

Copied

Hi

 

In an AEGP I'm building a function which can loop through all layers and effects in a given composition. 

The problem is that my effectsLen (number of effects on a layer) will return a very high number of several thousands even though there are only one effect in my test project.

What is weird is, if I exclude this line:

 

 

ERR(suites.EffectSuite4()->AEGP_GetEffectMatchName(installedKey, &effectMatchName));

 

 

... it will work and effectsLen will correctly be 1. If I add it, effectLen will be wrong. I fail to see what these have to do with each other? The error message I get is actually a "Plugin ID is invalid".

 

 

static PF_Err
LoopThroughEffects
(
	AEGP_CompH		compH,
	AEGP_GlobalRefcon	plugin_refconP)
{
	PF_Err			err = PF_Err_NONE;
	AEGP_SuiteHandler	suites(sP);
	AEGP_PluginID		plugin_id;

	A_long				layersLen;

	ERR(suites.UtilitySuite6()->AEGP_RegisterWithAEGP(plugin_refconP, STR(StrID_Name), &plugin_id));
	ERR(suites.LayerSuite8()->AEGP_GetCompNumLayers(compH, &layersLen));

	for (A_long i = 0; i < layersLen; i++)
	{
		AEGP_LayerH				layer;
		A_long					effectsLen;

		ERR(suites.LayerSuite8()->AEGP_GetCompLayerByIndex(compH, i, &layer));
		ERR(suites.EffectSuite4()->AEGP_GetLayerNumEffects(layer, &effectsLen));

		for (A_long e = 0; e < effectsLen; e++)
		{
			AEGP_EffectRefH			effectRef;
			AEGP_InstalledEffectKey installedKey;
			A_char					effectMatchName;

			ERR(suites.EffectSuite4()->AEGP_GetLayerEffectByIndex(plugin_id, layer, e, &effectRef));
			ERR(suites.EffectSuite4()->AEGP_GetInstalledKeyFromLayerEffect(effectRef, &installedKey));
			ERR(suites.EffectSuite4()->AEGP_GetEffectMatchName(installedKey, &effectMatchName)); // This is the problem

			if (effectRef) ERR(suites.EffectSuite4()->AEGP_DisposeEffect(effectRef));
		}
	}

	return err;
}

 

 

Any help will be greatly appreciated.

- Jakob 

 

Update after more tests:

I have tried with AEGP_GetEffectName also. Same result.

I have put in a break point to check the values. Effects name will be "77 'M'" which also is wrong. Maybe a hint?

EffectsLen will change to "1869366048". 

When continuing I get the pluginID error. I have also tried with NULL as pluginID.

TOPICS
SDK

Views

59

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Feb 20, 2024 Feb 20, 2024

I have now found the problem. This line:

A_char	effectName;

Should be:

A_char	effectName[AEGP_MAX_ITEM_NAME_SIZE] = { '\0' };

I still don't understand why that would lead to a change in effectsLen. Non the less, the fully functioning function:

static PF_Err
LoopThroughEffects
(
	AEGP_CompH			compH)
{
	PF_Err				err = PF_Err_NONE;
	AEGP_SuiteHandler	suites(sP);

	A_long				layersLen;
	
	ERR(suites.LayerSuite8()->AEGP_GetCompNumLayers(compH, &layersLen));

	for (A_long i = 0; i < layersLen; i++)
	{
		A
...

Votes

Translate

Translate
Engaged ,
Feb 19, 2024 Feb 19, 2024

Copy link to clipboard

Copied

I still have problems with this. And I can't figure it out. The function now looks like this:

static PF_Err
LoopThroughEffects
(
	AEGP_CompH			compH)
{
	PF_Err				err = PF_Err_NONE;
	AEGP_SuiteHandler	suites(sP);

	A_long				layersLen;

	ERR(suites.LayerSuite8()->AEGP_GetCompNumLayers(compH, &layersLen));

	for (A_long i = 0; i < layersLen; i++)
	{
		AEGP_LayerH				layer;
		A_long					effectsLen;

		ERR(suites.LayerSuite8()->AEGP_GetCompLayerByIndex(compH, i, &layer));
		ERR(suites.EffectSuite4()->AEGP_GetLayerNumEffects(layer, &effectsLen));

		for (A_long e = 0; e < effectsLen; e++)
		{
			AEGP_EffectRefH			effectRef;
			AEGP_InstalledEffectKey installedKey;
			A_char					effectName;

			ERR(suites.EffectSuite4()->AEGP_GetLayerEffectByIndex(S_my_id, layer, e, &effectRef));
			ERR(suites.EffectSuite4()->AEGP_GetInstalledKeyFromLayerEffect(effectRef, &installedKey));
			ERR(suites.EffectSuite4()->AEGP_GetEffectName(installedKey, &effectName));

			if (effectRef) ERR(suites.EffectSuite4()->AEGP_DisposeEffect(effectRef));
		}
	}

	return err;
}

It is called in the IdleHook in the AEGP for every 200th IdleHook call. I figured the correct pluginID is already served as a variable "S_my_id", so I don't get the PluginID error now. I do still get the problem with both layersLen and effectsLen changing to very high numbers as soon as I call this line:

ERR(suites.EffectSuite4()->AEGP_GetEffectName(installedKey, &effectName));

This will lead to a runtime error: "Internal verification error, sorry. {effect_indexL out of range}". If I exclude that line from the loop, I get no errors.

 

- Jakob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 20, 2024 Feb 20, 2024

Copy link to clipboard

Copied

LATEST

I have now found the problem. This line:

A_char	effectName;

Should be:

A_char	effectName[AEGP_MAX_ITEM_NAME_SIZE] = { '\0' };

I still don't understand why that would lead to a change in effectsLen. Non the less, the fully functioning function:

static PF_Err
LoopThroughEffects
(
	AEGP_CompH			compH)
{
	PF_Err				err = PF_Err_NONE;
	AEGP_SuiteHandler	suites(sP);

	A_long				layersLen;
	
	ERR(suites.LayerSuite8()->AEGP_GetCompNumLayers(compH, &layersLen));

	for (A_long i = 0; i < layersLen; i++)
	{
		AEGP_LayerH				layer;
		A_long					effectsLen;

		ERR(suites.LayerSuite8()->AEGP_GetCompLayerByIndex(compH, i, &layer));
		ERR(suites.EffectSuite4()->AEGP_GetLayerNumEffects(layer, &effectsLen));
		
		for (A_long e = 0; e < effectsLen; e++)
		{
			AEGP_EffectRefH			effectRef = NULL;
			AEGP_InstalledEffectKey installedKey;
			A_char					effectName[AEGP_MAX_ITEM_NAME_SIZE] = { '\0' };
			A_char					effectMatchName[AEGP_MAX_EFFECT_MATCH_NAME_SIZE] = { '\0' };

			ERR(suites.EffectSuite4()->AEGP_GetLayerEffectByIndex(S_my_id, layer, e, &effectRef));

			if (!err && effectRef)
			{
				ERR(suites.EffectSuite4()->AEGP_GetInstalledKeyFromLayerEffect(effectRef, &installedKey));
				ERR(suites.EffectSuite4()->AEGP_GetEffectMatchName(installedKey, effectMatchName));
				ERR(suites.EffectSuite4()->AEGP_GetEffectName(installedKey, effectName));
			}

			if (effectRef) ERR(suites.EffectSuite4()->AEGP_DisposeEffect(effectRef));
		}
	}

	return err;
}

 

- Jakob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines