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

Executing AEGP from javascript

Explorer ,
Apr 20, 2010 Apr 20, 2010

Hello guys,

Thanks to Sacahr I understood how to execute Javascript from AEGP.

There is two main problem to this method:

-the aegp execution goes on without waiting the end of parameter setting through UI

-getting the parameter values from the UI is hard not impossible though

So I was thinking about an alternative which would be to execute my AEGP plugin from the javascript.

Is there a way to do that? I looked into the docs and could not find any method for that.

TOPICS
SDK
3.1K
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
Participant ,
Apr 20, 2010 Apr 20, 2010

Instead, of executing the AEGP through Javascript, which I don't know if its

possible, I think getting the parameter values is a better solution. You can

get the parameter values of any effect in AE, but its a lot easier if its an

effect authored by you.

Now you can get the plugin's install key and get the parameters according to

its index or by passing an extra pointer through the

PF_Cmd_Completely_General command from the AEGP. Now I know this is really

vague information i am giving you but I dont want to give you erroneous

information! So wait until shachar replies!

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
Explorer ,
Apr 20, 2010 Apr 20, 2010

One of the solution to give parameters to my AEGP is as you say to write a dummy effect, and let the AEGP plugin read the parameter from that plugin (like Motion tracking features seems to be doing).

I was just trying to do it from javascript, without a dummy effect. Then we can tell the AEGP when parameters are ready.

I want to do that beacause accessing parameter from java script means to execute scritp from AEGP while in the Idle hook.

the main problem of that is that you can get crash when closing AE (because of the "impossible to execute script with a modal window", due to "There is change to the file so do you want to save?" modal window)

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 ,
Apr 20, 2010 Apr 20, 2010

Thanks to Sacahr I understood how to execute Javascript from AEGP.

Sacahr????

you may just as well call me 'Mary queen of Scots'...

back to our issue.

i couldn't find a direct way of calling an AEGP via java script.

however you could consider this workaround:

when the user calls your AEGP, the AEGP launches the java script displaying a palette,

sets itself a flag that we will use later,

and the AEGP exits.

so now the user has a palette with which he fills in all the needed data.

when the user hits 'OK' (or whatever it is you have chosen), the java script writes the data to a file.

let's say this file is called... MaryQueenOfScots.txt

and it saves this file to C:/program files/MyNameIsNotThatComplex

the java script exits.

so after about 1/10th of a second, the AEGP gets an idle hook call.

it checks the flag we mentioned earlier, and sees that it should check if a file is waiting for it.

so it checks if a file called MaryQueenOfScots.txt exists in C:/program files/MyNameIsNotThatComplex.

if it does, it reads that data from the file, deletes the file, sets the flag back to FALSE, and finishes the process now that it has the data.

if it doesn't, it means the user hasn't finished entering data into the palette. so we wait for the next idle process to check again.

if you wish to be evil (and you shouldn't), you could keep the AEGP running in a loop, until the java script writes the file.

a less destructive way would be to call AEGP_CauseIdleRoutinesToBeCalled() on the first call to your AEGP,

and again at every idle hook call until the file gets created.

that is, only if you have no faith in AE calling the idle hook. (which i find pretty dependable)

as for that crash you describe involving scripts and idle hook.

i don't know that error.

does it apply to the process i described?

i hope not.

p.s.

gutsblow, you are no longer the worst mispeller of my name.

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
Participant ,
Apr 20, 2010 Apr 20, 2010

Two quick questions, will AEGP_CauseIdleRoutinesToBeCalled() work if I call

it from a dummy effect? or i should only use it in an AEGP? Also, since we

can use Javascript to make dialogues in AE, do you think it is a viable

option to create user string input dialogs instead of messing with system

level commands? (like javascript dialogue->text file->plugin retrieves it).

Thank you very much for taking time.

BTW, I spell your name "Shachar" correctly now, after a lot of unsuccessful

attempts. But, you are definitely the Queen Mary in this forum!

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 ,
Apr 20, 2010 Apr 20, 2010

as far as i know you can call AEGP_CauseIdleRoutinesToBeCalled() at any time from both effects and AEGPs.

it will call all plug-ins (effects and AEGPs) who have an idle hook or a custom UI, and not just the plug-in that did the calling.

as for java vs. os window,

i must say i was surprised by the fact the the executeScript() function returned before the java palette exits.

perhaps because the window opens as a palette?

i get around java well enough for my needs, but i'm definitely no expert.

is there a way to open a java window as a movable modal?

maybe that would prevent the function to return before the window is done.

thus far problem number 1.

now how do we transfer the data from the java window back to the AEGP?

i haven't a clue.

on os level windows you could send a structure to the event handler, that the AEGP (or effect) will receive filled as soon as the event loop terminates.

furthermore, you could use the same functions you use in your effect, in the window (to me that's handy).

you can't do that using java.

so what's the bottom line?

besides longer coding times, os level windows are far more flexible and easier to work with as part of an otherwise pure C++ project.

if you want to go crazy, you could build a library using VB or java with window managing functions, and use it's functions in your C++ project.

but it seems to me it would be easier to just open some os level windows and get it over with.

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
Explorer ,
Apr 20, 2010 Apr 20, 2010

as far as i know you can call AEGP_CauseIdleRoutinesToBeCalled() at any time from both effects and AEGPs.

it will call all plug-ins (effects and AEGPs) who have an idle hook or a custom UI, and not just the plug-in that did the calling.

as for java vs. os window,

i must say i was surprised by the fact the the executeScript() function returned before the java palette exits.

perhaps because the window opens as a palette?

i get around java well enough for my needs, but i'm definitely no expert.

is there a way to open a java window as a movable modal?

maybe that would prevent the function to return before the window is done.

you can create a modal window :

var my_palette = new Window("dialog","Window Title");

my_palette.show();

BUT, eecuteScript() function will return as soon as you executed the

script...

thus far problem number 1.

now how do we transfer the data from the java window back to the AEGP?

i haven't a clue.

on os level windows you could send a structure to the event handler, that the AEGP (or effect) will receive filled as soon as the event loop terminates.

furthermore, you could use the same functions you use in your effect, in the window (to me that's handy).

you can't do that using java.

As i wrote in the previous post, you can execute some script just to get

some value of some javascript variables. Something like:

In the javascript UI:

var myparam;

function getParam(){

return myparam;

}

in the aegp:

executeScript("getParam()", result)

//analyze the result...

so what's the bottom line?

besides longer coding times, os level windows are far more flexible and easier to work with as part of an otherwise pure C++ project.

if you want to go crazy, you could build a library using VB or java with window managing functions, and use it's functions in your C++ project.

but it seems to me it would be easier to just open some os level windows and get it over with.

I m beginning to think that the only solution would be to use C++ coded

UI.... Using the Javascript would be portable, elegant, easy to develop,

but it is really hard to workaroun in a simple way the communication

between AEGP and javascript UI.

I may try to use QT inside an AEGP plugin, to see if it can work to

avoid the OS issues and Win32 programming that is really nasty (to my

opinion)

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
Explorer ,
Apr 20, 2010 Apr 20, 2010

shachar carmi さんは書きました:

>> Thanks to Sacahr I understood how to execute Javascript from AEGP.

>>

Sacahr????

you may just as well call me 'Mary queen of Scots'...

Dear Sachar, i m sorry for mispelling your name. But as said gutsblow,

you are kind of queen of Scots in that forum. I dont what I could do

without your precious help.

The solution you proposed is to use a file to dialog between the

javascript window and the aegp plugin. There is some issues considering

the permissions for the user and the deletion of the file by the aegp

while the javascript is writing it, but it should be manageable.

If I write a file, I think it could be equivalent to create an effect to

set up the parameter of the javascript UI and to delete it after with

the AEGP. But then I would need to create the parameter effect...

as for that crash you describe involving scripts and idle hook.

i don't know that error.

does it apply to the process i described?

i hope not.

This crash happens with the workaround I used to get the parameter back

from my javascript.

It was kind of nice workaround until that crash.

The principle is to call javascript function to:

1-During Command hook: create the UI (by calling aegp_executescript)

2-During Idle: call a function to check a javascript flag to know if OK

button has been clicked and the window closed.(by calling

aegp_executescript)

3-During Idle: if OK button has been clicked, then call various

javascript function to get all parameters (by calling aegp_executescript)

The 2 and 3 part is tricky because to check flag and parameters you have

to analyse the

AEGP_MemHandle*outResultPH0 from the call to AEGP_ExecuteScript. The

format of this result is totally undocumented, so you have to analyze by

yourself... By using some hex editor and debugger, you will understand

that numbers are changed to ascii characters. I have to investigate more

to know about the other types.

The problem with that method is that during Idle, the AEGP_ExecuteScript

is called. It will be called as long as the dialog is not closed. And

the consequences is a crash if you try to close After Effects without

closing the javascript UI. The error message is something like "Cannot

execute a script with modal window". The javascript UI is not modal...

But the window that ask you before closing After Effects "Do you want to

save the change to your project?" is modal. So maybe that s why I get

this error.

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 ,
Apr 21, 2010 Apr 21, 2010

salvati marc wrote:

Dear Sachar, i m sorry for mispelling your name.

for the love of god, Sachar is not my name either!

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
Explorer ,
Apr 21, 2010 Apr 21, 2010
LATEST

Shachar!

really sorry ><.

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