FORUMS: list search recent posts

How to launch a javascript with DoCommand in C++?

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ben Klewais
How to launch a javascript with DoCommand in C++?
on Apr 9, 2019 at 8:36:06 pm

Summary: Whenever I use AEGP_DoCommand in C++ to trigger a menu item that launches a Javascript file, AE crashes after executing that JS file.

I’m developing a script (javascript) that creates layers and automates multiple actions. Complementary with that is an effect (C++ plugin) that has no visible influence on the footage, but has a number of parameters (colours, sliders, buttons). The layers generated with javascript are linked with expressions to the effect’s parameters, so we can control them throughout the different comps.

One of the parameters is a button that should start a bunch of actions. Those are all written in a javascript file that works on it’s own. To launch that javascript file from the C++ effect I use:

---- suites.CommandSuite1()->AEGP_DoCommand(8109);

to trigger the menu item that corresponds to that script (File > Scripts > TheScript.jsx) (I found the ID with a simple script that uses app.findMenuCommandId() like suggested in the SDK guide.)

That script runs perfectly fine, I can still display an alert on the last line of the file.
Right after that script is done (and maybe when the AEGP_DoCommand function returns), After Effects crashes with the error attached. (BEE_WorkQueue)

To debug this, I tried launching a really simple script that just makes a new null.
That first executes, but right after, AE still crashes with the same error.

After this I tried doing a different command, like ‘Play/Pause’ (ID: 10314) and that worked perfectly fine, without any crashes.

I also looked into AEGP_ExecuteScript, but we have a pretty complicated script that applies presets and we lose the references to the presets when using ExecuteScript.

Is there a way to launch a script from the menu with the DoCommand function?

I hope my explanation makes sense, let me know if I can provide any more information!
Thank you!
Ben Klewais

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 All Rights Reserved