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

Custom Expression Functions

New Here ,
Sep 26, 2017 Sep 26, 2017

Hi,

I'd like to know if it's possible to create custom expression functions with the plugin SDK.

For example, say I wanted to allow users to enter the following expression: "getThingamabob(2, 'yes')". is there any way to "provide" the "getThingamabob" function from a plugin with the SDK?

I've scoured through the SDK guide to see if it mentions anything, but haven't had any luck.

TOPICS
SDK
1.3K
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 ,
Sep 30, 2017 Sep 30, 2017

to the best of my knowledge, it's not possible.

perhaps ZacLam​ would know better.

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
New Here ,
Oct 02, 2017 Oct 02, 2017

Dang, that's a shame. Looks like I'll have to find some way to work around it.

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
Guest
Oct 09, 2017 Oct 09, 2017

Yes, that should be easily doable:

You just create an AEGP C++ plugin file that creates a command ID and a command hook, something like this:

    ERR(suites.CommandSuite1()->AEGP_GetUniqueCommand(&S_Commando_cmd));

    ERR(suites.CommandSuite1()->AEGP_InsertMenuCommand(S_Commando_cmd, sPluginName.c_str(), iMenu, iMenuPosition));

    ERR(suites.RegisterSuite5()->AEGP_RegisterCommandHook(aegp_plugin_id, AEGP_HP_BeforeAE, AEGP_Command_ALL, CommandHook, 0));

    ERR(suites.RegisterSuite5()->AEGP_RegisterDeathHook(aegp_plugin_id, DeathHook,    NULL));

    ERR(suites.RegisterSuite5()->AEGP_RegisterUpdateMenuHook(aegp_plugin_id, UpdateMenuHook, NULL));

    ERR(suites.RegisterSuite5()->AEGP_RegisterIdleHook(aegp_plugin_id, IdleHook, NULL));

You can then call your custom commands globally from the AE scripting engine by either searching for the name using app.findMenuCommandId() or by directly calling it with app.executeCommand().

Transferring parameters is also possible, at least I managed to get this working some years ago

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
Enthusiast ,
Oct 09, 2017 Oct 09, 2017

Hi Toby,

Do you mean expressions can call commands just like scripts? It's very interesting! 🙂

How do you actually do that?

Cheers,

François

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
Guest
Oct 09, 2017 Oct 09, 2017

Aaaaaah, I think I understand now. I am sorry but I think I misread the original question. I was under the assumption of wanting to call plugin code from the scripting side, not from the expression side. Ok, in that case, forget my answer

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
Enthusiast ,
Oct 09, 2017 Oct 09, 2017

It was very promising... Probably too much 🙂

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
Enthusiast ,
Oct 11, 2017 Oct 11, 2017
LATEST

Hi tomb23568765!

there is one workaround:

expressions can read a file, and grab data from this file, like this:

$.evalFile("~/Desktop/myFunctions.txt");

So, you can write an AEGP plugin that creates a "myFunctions.txt" file on your desktop, and fill it with anything you want, like:

function getThingamabob(num, question) {

if (num == 2 and question == 'yes') {

          return true;

     } else {

          return false;

     }

}

Then, your expression will look like this:

$.evalFile("~/Desktop/myFunctions.txt");

getThingamabob(2, 'yes')

Cheers,

François

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