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

SDK: Detecting when a effect is removed

Engaged ,
Jul 10, 2023 Jul 10, 2023

Hi

 

I have setup where I need the effect I have created to send a message to a script. It have to do that when the effect is removed from the layer or when the layer on which the effect is, is deleted.

 

I tried this:

In the EffectMain:

case PF_Cmd_SEQUENCE_SETDOWN:
err = SequenceSetdown(in_data,out_data);
err = SequenceSetdown2(in_data, out_data);
break;

And then:

static PF_Err
SequenceSetdown(
	PF_InData* in_data,
	PF_OutData* out_data)
{
	PF_Err err = PF_Err_NONE;

	if (in_data->sequence_data) {
		AEGP_SuiteHandler suites(in_data->pica_basicP);
		suites.HandleSuite1()->host_dispose_handle(in_data->sequence_data);
	}
	return err;
}

static PF_Err
SequenceSetdown2(
	PF_InData* in_data,
	PF_OutData* out_data)
{
	AEGP_SuiteHandler	suites(in_data->pica_basicP);
	PF_Err				err = PF_Err_NONE;
	AEGP_MemHandle		resultMemH = NULL;
	AEGP_MemHandle		errorMemH = NULL;
	AEGP_GlobalRefcon	globalRef = NULL;
	const A_char* pluginName = STR(StrID_Name);
	AEGP_PluginID		pluginID;

	ERR(suites.UtilitySuite6()->AEGP_RegisterWithAEGP(globalRef, pluginName, &pluginID));

	ERR(suites.UtilitySuite5()->AEGP_ExecuteScript(pluginID, "callScriptFuntion", TRUE, &resultMemH, &errorMemH));

	if (resultMemH) ERR(suites.MemorySuite1()->AEGP_FreeMemHandle(resultMemH));
	if (errorMemH) ERR(suites.MemorySuite1()->AEGP_FreeMemHandle(errorMemH));

	return err;
}

That does not call the function when the effect is removed or the layer is removed. But it is called when the project is closed (which I actually don't want).

 

Any help on how to do this is greatly appriciated.

 

- Jakob

TOPICS
SDK
298
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 1 Correct answer

Community Expert , Jul 10, 2023 Jul 10, 2023

well... it's a bit of a tricky problem.

what does constitue as a removal? the user hit's "cut". the effect can now be re-applied, or the operation can be undone. was the effect "removed" or was it in limbo?

AE destroys an instance only when it's deletion is out of the undo stack (i.e. 100 undo steps). similarly, closing the project or purging memory destroy the undo stack and result in destruction of instances suspended in the undo stack.

 

there's no API for telling an effect has been removed f

...
Translate
Community Expert ,
Jul 10, 2023 Jul 10, 2023

well... it's a bit of a tricky problem.

what does constitue as a removal? the user hit's "cut". the effect can now be re-applied, or the operation can be undone. was the effect "removed" or was it in limbo?

AE destroys an instance only when it's deletion is out of the undo stack (i.e. 100 undo steps). similarly, closing the project or purging memory destroy the undo stack and result in destruction of instances suspended in the undo stack.

 

there's no API for telling an effect has been removed from a layer, but you can deduce it by scanning the project on idle hook looking for instances of your effect and cataloging them. if an effect was there on one scan and is missing on the next, you can tell it was removed. the problem is it's not an immediate operation, as it happens in the next idle hook call after the deletion. stuff might happen in that time window, so if you absolutely must act immediately on deletion, this method is no good.

 

you can also try to monitor "cut" and "delete" operations by adding command hooks, but this method is a MAJOR pain... not all user methods for cutting and deleting trigger the menu commands. for instance, if a deletion is undone and then redone, the redo doesn't trigger the delete menu command, it just sets the project to a state.

 

i think you should start by well defning what constitutes a "removal" for you, and then maybe i could come up with ideas would play well to that scheme.

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 ,
Jul 11, 2023 Jul 11, 2023
LATEST

OK. Thank you for info. When I say removed, I mean from the users perspective. So that would include cutting.

I have already been working on a script that runs a couple of times a second and compares the comp layers to see if any chages have happened. But I was hoping for a cleaner solution.

I have tried using an IdleHook (if for nothing else then just to learn). And did this:

static A_Err
IdleHook(
	AEGP_GlobalRefcon	plugin_refconP,
	AEGP_IdleRefcon		refconP,
	A_long*				max_sleepPL)
{
	PF_Err				err = PF_Err_NONE;
	AEGP_MemHandle		resultMemH = NULL;
	AEGP_MemHandle		errorMemH = NULL;
	AEGP_GlobalRefcon	globalRef = NULL;
	const A_char* pluginName = STR(StrID_Name);
	AEGP_PluginID		pluginID;
	AEGP_SuiteHandler	suites(in_data->pica_basicP);

	ERR(suites.UtilitySuite6()->AEGP_RegisterWithAEGP(globalRef, pluginName, &pluginID));

	ERR(suites.UtilitySuite5()->AEGP_ExecuteScript(pluginID, "callFunction()", TRUE, &resultMemH, &errorMemH));

	if (resultMemH) ERR(suites.MemorySuite1()->AEGP_FreeMemHandle(resultMemH));
	if (errorMemH) ERR(suites.MemorySuite1()->AEGP_FreeMemHandle(errorMemH));

	return err;
}

That doesn't work for the obivous reason that inData isn't available. My question is; is it not possible to access the suites in an IdleHook?

 

Thanks,

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