Skip to main content
Inspiring
April 5, 2024
Answered

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

  • April 5, 2024
  • 1 reply
  • 670 views

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

Correct answer octaviosa

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.

1 reply

Community Expert
April 7, 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...

Inspiring
April 8, 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;
}