Path to After Effects for scripting

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

I'm writing a script to trigger an AE script from Photoshop. On a PC it's pretty obvious to find. "AfterFX.exe" My script line can just read

Code: Select all

C:\Adobe\After Effects 7.0\AfterFX.exe -s "alert("Hello")"
On a mac, I'm unsure of what to point the script to. It doesn't appear that "AfterFX.exe" exists. Would I tell it to point to the "Adobe After Effects 7.0.app" file? Has anyone had any luck starting After Effects scripts on a mac from other places?
zold

Hi Byron.
As I'm sure you've seen in the Scripting Guide, The 'preferred' method of getting AE to run a jsx in an automated fashion on Darwin/OSX is to use AppleScript. Of course, you're not talking about applescript (the much-maligned), are you? So I feel the need to get a clarification before typing a lot :) ...
You want to run an ECMA script in Photoshop that makes AE run another ECMA script -- is that right? -- but ideally do you want this script to be in text form or to be a file of the text? Are you building the AE script on the fly? There are some interesting (if not annoying) ways to use the osascript command to run an applescript (well, osa script, but nevermind). One way is to have a file that contains applescript text which contains a handler (subroutine) that can accept an argument, then use the osascript command to send it js text. Is this even close to what you want to do? Another way is to have an applescript application sitting around that can be executed without osascript (using

Code: Select all

system.callSystem('open ' + aPathToScriptApp);
) but it won't take arguments, I don't think. Can you sort of map out what your ideal solution is? Maybe I can help. Just don't want to open up a can of worms for you. Or, if I do, I want that can of worms to be extra tasty. Or am I overthinking this?
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

Thanks for the info zold. I'll try to outline what I'm doing to further clarify. I have built an elaborate workflow using Photoshop and After Effects. The PS script automates the preparation of a bunch of images. The After Effects side plugs all the created images into a large custom project. I'm trying to link the two together so that the user can run the PS script and not have to go over to AE and run that one after completion. Over on PS-Scripts.com someone showed me a way to execute shell scripts on the mac. It's tricky, but I think I have it close to working if I can get the path to AE correct. I made an applescript solution but it retained some keyboard focus during the PS execution and I can't have that. I don't need to send any arguments to AE when triggering it. The only piece of data needed is stored in a temporary text file on the desktop. I don't think that PS has the callSystem function or I would use it. What I plan to do is have PS write a shell script that writes a javascript that tells AE to run a another script. Confusing huh? I have it working on the PC using a batch file. For some reason, executing files on the mac is not as simple as the PC. I hope that helps.

P.S.- I'm still looking for the path to AE on a mac
nab
Posts: 203
Joined: November 29th, 2005, 3:00 am
Location: Royan
Contact:

Hi Byron,

I don't know if that helps but what you can do is "Thinking inverse".

Rather than viewing your workflow as "I start first with PS because PS is required to treat my bunch of images, then I call AE because AE is required to create the final project", you can view it as "Okay, I'm already in AE because this is where my result comes from; I call PS because I need to treat my images first,..."

There is a 'special' folder where you can place some "adobe app startup scripts" :

Code: Select all

C:\Program Files\Common Files\Adobe\StartupScripts
When the AE script will open PS, the PS script may be executed automatically (write the infos you need in a text file), and you retrieve your data directly in AE to finalize..

ps: I don't know if that works similarly on a Mac, but on Windows I have couple of script that use this method to connect the two apps.
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

That's not a bad idea nab, I'll look into it. AE seems to be able to interact with the system much better than PS.

From what I'm gathering though is that no one really knows what the path to AE is for running command line scripts?
zold

byronnash wrote:Over on PS-Scripts.com someone showed me a way to execute shell scripts on the mac.
I just took a look over there. Pretty cool, a bit cumbersome, esp. if you're not used to the OSX world.
byronnash wrote: It's tricky, but I think I have it close to working if I can get the path to AE correct.
I noticed that the examples over at PS-Scripts.com seemed to be sort of Windows/Mac amalgams. One of these two should work:

Code: Select all

"/Applications/Adobe After Effects 7.0/Adobe After Effects 7.0.app/"
or'

Code: Select all

"/Applications/Adobe After Effects 7.0/Adobe After Effects 7.0.app/Contents/MacOS/After Effects"
The first references the Application package, the second the binary executable within the package. (I would use the first if usng system.callSystem('open ' + appPath), for example; the second if directly launching an instance of AE from the terminal/shell script -- sucks that -s doesn't work for this)
byronnash wrote:I made an applescript solution but it retained some keyboard focus during the PS execution and I can't have that.
Now that I'm very curious about (AS was my first scripting language, and most of my automation solutions, apart from AE jsx's and some other stuff, are in AS). Seems to be you should be able to use AS without user-interaction. I'm guessing your solution ran a script in PS, then ran a script in AE, and the period in-between was tricky, because the AS script had to know when the first script was done. Yes?
byronnash wrote:I don't think that PS has the callSystem function or I would use it.
Yeah, DUH on my part. I didn't realize that was missing from the PS command set. Bummer.
byronnash wrote:What I plan to do is have PS write a shell script that writes a javascript that tells AE to run a another script. Confusing huh?
Confusing, but somewhat familiar. Interapplication Communication is one of my specialties. If it isn't obvious, I have it in my head that this can be accomplished with AS -- but it sounds like you're about ready to use a different method. Let me know if it works, and if you'd like to reconsider an applescript method. Regardless, if I can help in any way, let me know.

-CG
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

After further digging and more careful reading I have determined that you cannot send scripts to AE on a Mac the same way you can with a PC. To send a script to AE, you must use applescript, it cannot be done with the shell. So, if I get my shell script working, I will have it call an applescript. This all sounds so ridiculous. JSX run from PS and writes a shell script that launches an applescript that launches an AE JSX.

The applescript solution I have is working pretty well. My client is telling me that when the script calls a crop tool in PS that the keyboard doesn't respond. The keyboard does respond when running the PS script natively. I figured since applescript is running PS and the script that applescript isn't giving up total control.

I guess my two options are

-find the problem with the keyboard not working

-run PS from AE and eliminate the need to use applescript and shells.

Thanks for the discussion guys.
zold

byronnash wrote:This all sounds so ridiculous.
I totally agree. If they would get -s to work on OSX this would be cross-platform. Or moreso.
byronnash wrote:when the script calls a crop tool in PS that the keyboard doesn't respond.
Do you mean you need user interaction during the process, or that the script kills the keyboard functionality?
Have you tried (and this may not work for what you're doing -- I of course am unclear as to what the interaction/timing issues are) putting that part of the AS code in an "ignoring application responses" block?

Code: Select all

--//--//--//--// danger! off-topic code!
ignoring application responses
--tell ps to do crop stuff
end ignoring
this means the script won't wait for anything to be returned from the 'crop stuff' so that may be a problem.

The 'run from ae' idea seems good, too.

best o' luck!

-cg
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

Has this changed since CS4 or CS5? I would like to just get the path to the app or to aerender.
Post Reply