Pyblish for After Effects


#1

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";
try
{
    commandLine += " --scene " + app.project.file.fsName;
}catch (e)
{
    commandLine += "";
}

app.project.save()

system.callSystem(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.


#2

Nice!!

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?


#3

No, unfortunately not:(


#4

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");

myFile.execute();

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


#5

That’s great news!


#6

Back on this again, and wanna try to get a more flexible solution. Saw this post, and it works; http://techartsurvival.blogspot.co.uk/2014/01/talking-to-photoshop-via-tcp.html

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


#7

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


#8

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.


#9

Here is my first little prototype; https://github.com/tokejepsen/pyblish-aftereffects/tree/9fc76b9b9d9fc86761a4d54531c8fb39e47d5085/pyblish_aftereffects

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

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


#10

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.


#11

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?


#12

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.


#13

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.


#14

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; http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/photoshop/pdfs/photoshop-cc-vbs-ref-2015.pdf, but After Effects doesn’t have any VBScript doc; http://www.adobe.com/devnet/scripting.html.


#15

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

https://github.com/pyblish/pyblish-standalone/blob/master/pyblish_standalone/main.py#L49

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


#16

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.


#17

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?


#18

That would be QApplication.exec_().

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


#19

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.


#20

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.