Copy link to clipboard
Copied
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
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...
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.
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Your're right. I still haven't found a reliable way to do this.
Copy link to clipboard
Copied
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...)
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now