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

SDK Create a map of install keys and matchnames

Engaged ,
May 16, 2024 May 16, 2024

Copy link to clipboard

Copied

Hi

 

I thought I was real clever when I did this. LOL. The problem is, I can't get it to work. The idea was to put all the install keys and matchname couples into a map. That way i could quicly get the right install keys without having to loop through installed effects every time. Problem is, I keep getting the wrong install keys, which results in the effect added is the wrong effect.

Can anybody see what I'm doing wrong?

 

The classes looks like this:

h:

class InstallKeys
{
public:
	static std::map<A_char, A_long>	keys;
};

class AEGPTools
{
public:
	static PF_Err	SetupInstallKeys(SPBasicSuite* sP);
};

 cpp:

std::map<A_char, A_long> InstallKeys::keys;

PF_Err AEGPTools::SetupInstallKeys(SPBasicSuite* sP)
{
	PF_Err					err = PF_Err_NONE;
	A_long					numInstalledEffects;
	AEGP_InstalledEffectKey	nextKey;

	AEGP_SuiteHandler suites(sP);

	ERR(suites.EffectSuite4()->AEGP_GetNumInstalledEffects(&numInstalledEffects));
	ERR(suites.EffectSuite4()->AEGP_GetNextInstalledEffect(AEGP_InstalledEffectKey_NONE, &nextKey));

	while (!err && nextKey)
	{
		A_char nextMatchName[AEGP_MAX_EFFECT_MATCH_NAME_SIZE] = { '\0' };

		ERR(suites.EffectSuite4()->AEGP_GetEffectMatchName(nextKey, nextMatchName));

		InstallKeys::keys[*nextMatchName] = nextKey;

		ERR(suites.EffectSuite4()->AEGP_GetNextInstalledEffect(nextKey, &nextKey));
	}

	return err;
}

I can then run this once when the app starts:

AEGPTools::SetupInstallKeys(sP);

And then apply an effect like this:

AEGP_EffectRefH			effectRef;
A_char					myMatchName[AEGP_MAX_EFFECT_MATCH_NAME_SIZE] = "ADBE Gaussian Blur 2";
AEGP_InstalledEffectKey	installKey = InstallKeys::keys[*myMatchName];

ERR(suites.EffectSuite4()->AEGP_ApplyEffect(S_my_id, layer, installKey, &effectRef));

But as said, it applies the wrong effect.

 

Thanks,

Jakob

TOPICS
SDK

Views

181
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

Community Expert , May 16, 2024 May 16, 2024

err... i think you're storing just one A_char in the map and not the full string...
shouldn't the map be declated with a string type (or at least an array of A_char) and not just the A_char type?

Votes

Translate
Community Expert ,
May 16, 2024 May 16, 2024

Copy link to clipboard

Copied

err... i think you're storing just one A_char in the map and not the full string...
shouldn't the map be declated with a string type (or at least an array of A_char) and not just the A_char type?

Votes

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 ,
May 16, 2024 May 16, 2024

Copy link to clipboard

Copied

LATEST

Arh, you're right. I keep messing up with strings and char arrays. 

Thanks!

Votes

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