Copy link to clipboard
Copied
I have my custom jsx script(myJSXScript_UI.jsx) with UI and custom functions written for after effects to run from File > Script >run script.
Now am trying out writing an extension for after effects where i can call some function from above jsx script directly using CSInterface.
So, i have added my jsx script path in manifest file and i have setup a button onClick() event in index.html and am calling my custom function using CSInterface. Please find the attachment for index.html and manifest file snapshots for your reference.
Now my problem is, when i click that button in extension, my functions are running fine and executed, but UI of the jsx script is opening as well. What is the reason?
Currently, i have removed panel.show() in jsx script to avoid UI, but that's not ideal solution.
If am calling some function() why entire script is opening with UI.
Whats wrong and whats the other way to do this?
Please help!
Since all Ae scripts share the same global space, you could do the following:
Your jsx script checks if a global variable "showUserInterfaceOfMyAfxScript" exists and has the value false. If that is the case, it does not create the user interface AND sets the showUserInterfaceOfMyAfxScript to true again.
When you execute your script from the CEP panel, first execute this script
showUserInterfaceOfMyAfxScript = false;
then execute your myAfxScript.jsx
Note that it is crucial that myAfxScript.js
...Copy link to clipboard
Copied
When you add the script to your manifest, I would assume that it is executed when your CEP panel is launched (so the jsx script UI should appear at the point in time where also your CEP panel UI appears). But from what you say it seems that Ae is only executing the jsx script lazily when the first actual jsx code is executed from the panel (just a guess, not sure if this is really what is happening behind the scenes).
In general, if you want your CEP panel to use code from your jsx script but you don't want the UI of the jsx script to show up, removing the part of the code that creates the UI (like panel.show()) is the only thing that makes sense, right? Why would you want to execute code that says "please show this panel" if you don't want it to be shown?
Copy link to clipboard
Copied
Thank you for ur reply!My idea is to just use functions in my existing jsx file and get returned results without modifying jsx file...So tat, jsx file can be used as a script to launch from File > script > run and also used for extension to only use its existing functions and get returned results..
I ll put in this way briefly..
MyAfxScript.jsx
--------------------------
var p= new window ();
P.add(button1,2,3 );
P.show();
button1.onClick = run function A();
button 2.onClick= run function B();
button3 .onClick=run function C();
function A(){do something and return result}
function B(){do something and return result}
function C(){do something and return result}
--–---------------
My extension(index.html)
---------------
<body>
<script src=MyAfxScript.jsx>
<button onClick=function A()>
<button onClick=function B()>
<button onClick=function C()>
</body>
Hope u understood my problem?
Copy link to clipboard
Copied
Since all Ae scripts share the same global space, you could do the following:
Your jsx script checks if a global variable "showUserInterfaceOfMyAfxScript" exists and has the value false. If that is the case, it does not create the user interface AND sets the showUserInterfaceOfMyAfxScript to true again.
When you execute your script from the CEP panel, first execute this script
showUserInterfaceOfMyAfxScript = false;
then execute your myAfxScript.jsx
Note that it is crucial that myAfxScript.jsx sets
showUserInterfaceOfMyAfxScript = true;
again after not creating the user interface. Because otherwise if the user decides to execute myAfxScript.jsx himself later in the session, the variable is still false and the UI won't show up.
That's kind of what I do in the API's of my After Effects tools:
https://mamoworld.com/article/kbar-and-scripting-apis
except that I use variable
kbar = { button:{argument:"getAPI"}};
instead of a variable
showUserInterfaceOfMyAfxScript = false;
such that the script functions can also be executed by the tool Kbar easily.
Copy link to clipboard
Copied
Nice ! I ll give it a try.
Am facing another issue when i call a function in my JSXScript from an extension., the
Copy link to clipboard
Copied
Not sure why this is happening, but if your CEP panel executes the script file, it must know where this script is, right? So you could again use the workaround with a global variable where you store the file path in that variable before actually executing the script.
Just make sure you use variable names that will not overlap with variables used by other scripts.
So "filePath" is not a good name but "myCompany_MyScriptName_version_filePath" is one.
Copy link to clipboard
Copied
I learnt sign and make zxp, extract it and make sfx archive, give it to user, install, extract to USER/appdata/roaming......./cep/extensions/ to avoid admin credentials for programFiles(x86).As u mentioned, i already declared this path as global variable using Folder.userData/adobe/cep/extensions. But, am curious to know why it didn't happen thru File("$.Filename")?
As am relatively new to extensions, html, js.I ll share my basic extension template which am using and if u can help me with that to achieve method 01, it would be really helpful.Method 01 Template below (calling function directly).
https://drive.google.com/file/d/1ieEIyc_F_q6OHHid14fM__j65YTuxHdb/view?usp=sharing
Please note that i was doing like below.
Method 1
--------------
At manifest file
<ScriptPath>myAfxScript.jsx</ScriptPath>
At index.html
csInterface.evalScript(someFunction() from myAfxScript.jsx) where new File($.fileName) returns the program files path of premiere pro.
Method 2
----------------
removed <ScriptPath> at manifest file
at index.html
csInterface.evalScript('$.evalFile(myAfxScript.jsx)') where, new File($.fileName) returns correct path of myAfxScript.jsx.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more