Highlighted

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

New Here ,
Apr 09, 2019

Copy link to clipboard

Copied

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 controls 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)

After Effects Crash Error.png

To debug this, I tried launching a really simple script (attached below) that just makes a new null.

That first executes, but right after, AE still crashes with the same error.

SampleScript.png

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

Topics

Scripting

Views

154

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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

New Here ,
Apr 09, 2019

Copy link to clipboard

Copied

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 controls 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)

After Effects Crash Error.png

To debug this, I tried launching a really simple script (attached below) that just makes a new null.

That first executes, but right after, AE still crashes with the same error.

SampleScript.png

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

Topics

Scripting

Views

155

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
rkudinov LATEST
Community Beginner ,
Mar 20, 2020

Copy link to clipboard

Copied

Hi, if you still experience the problem you may try to launch your script function through app.scheduleTask. This fixed the crashes for me.

E.g.:

 

function main()

{

    app.scheduleTask("workingRoutine()", 1000, false);

}

 

main();

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...