Pyblish for After Effects


So with the help of pyblish-standalone, I’m now able to launch Pyblish from After Effects.

I’m using this script;

var commandLine = "K:/development/tools/pyblish/pyblish.bat";
    commandLine += " --scene " + app.project.file.fsName;
}catch (e)
    commandLine += "";


I’m experiencing a freeze of AE after this call though, which I’m struggling with:s If anyone has any suggestions, I’m all ears.



The freeze is likely because the process you are calling is blocking and After Effects is waiting for it to finish. It likely won’t unfreeze when you close the GUI either, because of the raw_input() holding onto the process until you hit enter.

Does it unfreeze when you close the Pyblish Standalone terminal?


No, unfortunately not:(


I’ve got some progress on this.

Calling the command line with the arguments seems like a lost cause, since After Effects locks up and its unresponsive after closing the terminal.

The solution is to execute the bat file instead, and use environment variables to pass data along. The script for After Effects looks like this;

$.setenv("PYBLISHARGUMENTS", "value");

var myFile= new File("K:/development/tools/pyblish/pyblish.bat");


Next is just to create another plugin for pyblish-standalone, which collects the arguments in the environment variable.


That’s great news!


Back on this again, and wanna try to get a more flexible solution. Saw this post, and it works;

My thoughts are that we could have function that accepts a string for execution. You could then execute a ExtendScript string and get all the data you want.

If anyone know ExtendScript I would appreciate help on this, but will update here as I go along:)


If ExtendScript is anything like Javascript, I might be able to help.


Should be pretty much the same. Don’t know where the two differ, but its Adobe’s Java flavour.
I guess they have pretty much just added some variables for interacting with the AE products.

Good thing is that if we can crack this, it should open up for all Adobe products.


Here is my first little prototype;

Run server.jsx in AE. This will put AE into server mode, and wait for incoming commands. This locks AE though:s

Execute in a terminal. This will return the application version and stop the server from running in AE.


Neat. :slight_smile:

Locking AE shouldn’t be a problem. In practice, when the publishing dialog pops up, it would simply appear to have taken priority. Like most dialogs in AE anyway.

Secondly, I’m sure there is a way to not have it lock. Javascript is a highly asynchronous language, should just be a matter of finding the right callback in place for the while loop you’ve got there.

Thirdly, I was sure there already was already a way of connecting to an Adobe app, without starting a server. If it’s anything like Photoshop, then these might help.


I can’t remember why I abandoned the com interface, but I did investigate it the last time. Note to self, to make notes to self:)

There is one problem I might forsee which is that you can have multiple instances of AE running with the -m command flag.
Also using win32com module I’m guessing limits it to Windows?


Got a working version… kinda :worried:

Run the server.jsx, which will launch pyblish-lite and go into server mode.

I had to make pyblish-standalone accept an optional “–port”.

Now the problem is how to stop AE serving again, when done :s Guessing this is where I’ll get into similar issues as with pyblish-qml not shutting down correctly etc.
Thinking I might be able to send a “stop server” command when closing down pyblish-lite. Will just be a problem if the user closes the terminal window first.


That could be a problem, if the COM interface doesn’t let you specify a target connection or if Adobe hasn’t put something in place to let you choose a target at run-time. I would be surprised if at least one of those wasn’t true.

That’s a good point, that does sound likely. But again, I wouldn’t be surprised of they had something similar in store for OSX.

Yes, welcome to my world. :slight_smile:

As with QML, I would first try and find a way in which you don’t need to have it shutdown on closing the GUI. See if there’s any way of having your server run asynchronously.

Once you’re sure there isn’t a way, then the only reliable way I know is to start dealing with heartbeats. Having the server continuously ask “is there a client? is there a client? …” And once the GUI isn’t there to reply, shutdown.

It’s ugly (I think) but such a common and accepted practice that you’ll find plentiful of resources about how to go about it online. Especially with a Javascript server, which is what frameworks like Node.js is all about.


Researching the com interface with After Effects, I think my problem was the lack of documentation. For exploring the methods for Photoshop you can look at the VBScript functions;, but After Effects doesn’t have any VBScript doc;


What is the reason for waiting for a keyboard entry when closing down pyblish-standalone?

Could we not just shutdown the terminal, when the user closes the ui?


Sure, that could work.

It just has to wait for something, as otherwise the process quits when showing the GUI, which would kill the GUI immediately.

You’ll just need to find a way of having a window show and block, so that closing it means “go ahead to the next line”, where the next line is quitting the process.

For pyblish-lite, that might be setting a window flag. For pyblish-qml, that might involve forwarding the close-event into something you can listen or wait for. The point being, the blocking mechanism will differ across GUIs.


I’ve tried a test where I called the the GUI to show and on the next line called the something else like stopping the ae server.
It worked fine. The GUI was showing and I could continue to refresh. When I closed the ui, the terminal closed as well.
Now I don’t know whether there is some code in pyblish-lite that keeps the instance of the ui going, and if other uis would close immediately?


That would be QApplication.exec_().

It’s being called as soon as show() finished.


I’ve got a working version now that I’m going to roll with. Have limited time to experiment :frowning:

Its working quite nicely now. The user aren’t presented with a terminal window by using start pythonw, this prevents them from closing the terminal window before closing the pyblish-lite ui.


Its very specific to Windows atm, but we could probably convert it to Mac/Linux when the need comes.

It should also work for Photoshop and Illustrator. It could probably be presented nicer with a panel instead of executing a script.