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

SDK Detect if a new project have been opened or created.

Engaged ,
Apr 05, 2024 Apr 05, 2024

Hi

 

If I create an AEGP using the c++ SDK. Is it then possible to detect if a new project have been opened or created? Either by some type of event or in the IdleHook?

 

Somewhat related: Does the events descriped here work in AEGPs? https://ae-plugins.docsforadobe.dev/effect-ui-events/effect-ui-events.html 

 

Thanks,

Jakob

TOPICS
SDK
592
Translate
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 2 Correct answers

Community Expert , Apr 07, 2024 Apr 07, 2024

there's no direct way of telling, but it can be deduced.

during idle hook you can check the current file path, and compare it to the previous check you did. if it's changed, it's a new project.

perhpas you can use AEGP_GetIndProject and compare the pointer gotten... but i never tried it so i don't know if it's a reliable way...

Translate
Participant , Apr 11, 2025 Apr 11, 2025

Unfortunately this is not enough to detect new projects, because when you use "save as" and set a different filename, you would identify it as a new project, even though it's not.

Translate
Community Expert ,
Apr 07, 2024 Apr 07, 2024

there's no direct way of telling, but it can be deduced.

during idle hook you can check the current file path, and compare it to the previous check you did. if it's changed, it's a new project.

perhpas you can use AEGP_GetIndProject and compare the pointer gotten... but i never tried it so i don't know if it's a reliable way...

Translate
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 ,
Apr 08, 2024 Apr 08, 2024

Thank you. That was the conclusion I got to, but wanted to check if I missed something.

I have tried using AEGP_GetProjectByIndex, but that doesn't seem to work. In my tests it returns true when comparing the pointers, even if a new project have been created.
I tried doing something like this:

static A_long				S_idle_count = 0L;
AEGP_ProjectH		*projPH;

static	A_Err
IdleHook(
	AEGP_GlobalRefcon	plugin_refconP,
	AEGP_IdleRefcon		refconP,
	A_long* max_sleepPL)
{
	A_Err				err = A_Err_NONE;
	AEGP_SuiteHandler	suites(sP);

	S_idle_count++;

	if (S_idle_count % 200 == 0)
	{
		AEGP_ProjectH		newProjPH;
		A_Boolean			isSameProject;

		ERR(suites.ProjSuite6()->AEGP_GetProjectByIndex(0, &newProjPH));

		if (projPH != nullptr)
		{
			isSameProject = *newProjPH == **projPH;
		}

		projPH = &newProjPH;
	}

	return err;
}

 

 

Translate
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
Participant ,
Apr 11, 2025 Apr 11, 2025

Unfortunately this is not enough to detect new projects, because when you use "save as" and set a different filename, you would identify it as a new project, even though it's not.

Translate
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 25, 2025 May 25, 2025

Your're right. I still haven't found a reliable way to do this. 

Translate
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
Community Expert ,
May 25, 2025 May 25, 2025

well, if you have one of your own effects applied wich utilizes sequence data, then you can add sequence_resetup to the deduction process. it occurs on numerous occasions, one of which is when a project is loaded.
1. new project path AND sequence_resetup = new project.

2. new project path WITHOUT sequence_resetup = same project, saved with a different name.

(again, not perfect, but getting there...)

Translate
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
Community Expert ,
May 25, 2025 May 25, 2025

another way to deduce using sequence data, is the flatten call. it should precede a save.

so:

1. flatten AND new project path = same project saved with a different name.

2. new project path WITHOUT flatten = new project.

 

in combination with the resetup calls, perhaps this would be above your precision needs.

by needs, i mean to ask what the risk here.

there are 4 scenarios:

1. true positive: when a new project is opened, and properly detected.
2. true negavie: when it's the same project saved to a different path, and it's properly detected.

3. false positive: when it's the same project, but falsly detected as new.

4. false negative: when it's a new project, but falsly detected as the same project.

so 1 and 2 a mint. no worries there.

what are the risks in 3 and 4? if only 4 (false negative) is the problem, pehraps the techniques you already have are good anough so no false negaive can occur, and the false positives are rare and cheap enough to just accept.

Translate
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 29, 2025 May 29, 2025
LATEST

Hi Shachar

Thank you for the input and suggestions, I'll check those out later. But yes, I have been modifying my code to work without detecting if a new project have been openned or created. That will be the safest way to go forward.

// Jakob

Translate
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