Archive for Scripting

Safari Extension To Remove URL Referers

I often need to wrangle web pages for publication and quite often copy/paste is littered with referer info and session junk. Luckily, many websites can generate a clean url by just stripping everything after a ? in the url. This Safari Extension does just that, opens a url in a new tab with everything to the left of the ? symbol retained so you can check if your new url is usable for publication. The extension is installed as a context menu used while hovering over an anchor link.


Comments off

Moving some things to github: Adobe Illustrator to Core Graphics Paths script

I’m starting to migrate some of my code to github and I’ve started with a script to export an Adobe Illustrator path to Core Graphics code in an Objective-C class. This is mainly useful for iPhone development, but also might be useful for anyone looking to parse EPS style graphics.

Adobe Illustrator Scripts for Core Graphics on github

Comments off

Oustanding geekery at

Looks like I’m a little late to the party, but I’m catching up with some great posts at I’ve always admired David Van Brink’s qt_tools project, A great open source command-line set of tools for dealing with Quicktime, and it looks like he’s now sharing more quick hits of his pixel, motion and scripting explorations. Very fun David.

Comments (2)

Doing something interesting with our Socket Object and XML; A slightly flawed Flickr reader for AE CS3 on the Mac

Last time, we talked about using a Socket Object in After Effects CS3 to parse a data feed with E4X XML parsing. There are a lot of useful workflow operations I can think of that could make use of data feeds, but After Effects is a visual medium, so let’s do something visual, let’s import a set of flickr photos matching a tag. This is a proof of concept script, and before you plunge into experimenting you should check the terms of service of the web feed provider and respect the use of images you download. That said, let’s take a look at some code.
Read the rest of this entry »

Comments (5)

Using the Socket Object to fetch XML for parsing in After Effects CS3

I had an email conversation with Matt, who wanted to fetch some xml to play with the new E4X XML parsing in AE CS3. We’re still waiting for the ExtendScript HttpConnection Object to show up in After Effects, but we do have access to the Socket Object. The Socket Object is a little low level, but if you are using web feeds and don’t need authentication it’s actually pretty easy.

This code segment outlines the basics.

webConnect = new Socket;
response = new String;

if("","UTF-8")) {

webConnect.write('GET /current/currentpicks?format=xml HTTP/1.0nn');

response    =;

response = response.toString();

var xmlStart = response.indexOf("<?xml");
var xmlString = response.substring(xmlStart, response.length);



} else {

alert (""unable to open webConnect via Socket"")


We open a Socket and connect to, in this case, a feedburner feed. We use the read() method to read in the XML, and since the Socket object includes the header we use indexOf to find the beginning of the XML and substring to read to the end of the line.

A couple of gotchas in the code. In this case the header tells us the document encoding is utf-8 so we explicity set it with"","UTF-8")

Also, when Matt and I were initially exploring this we were just getting the header. It looks like a GET request with

response    =

allows a block response, and the later content was going off into the ether, If we used

response    =;

with a sufficiently large number to include all of the XML we got all of the contents of the XML file. This seems like a really bad idea, since we’ll never know the size of the XML file unless we munge some headers and setting it arbitrarily high also seems like a bad idea. Can someone who’s spent more time with the Socket object leave a comment or email me on how to handle the block response or alternatives to setting a big count for the read() method? I’d appreciate it.

Anyway, that’s the basic idea. You’d then parse the xmlString variable and do fun stuff with it. One heads up, the sample above includes namespaces, so be sure to read the section on namespaces in the Scripting Guide.

Comments (2)

FCPToAE going (mostly) CS3 Only

Just a quick heads up that I’ve decided to focus my efforts on FCPToAE and related tools to the CS3 Suite only. With a strong subset of ECMA-357 (E4X) (pdf link) parsing in Extendscript 2, it doesn’t make a lot of sense to keep inventing workarounds to FCP-XML parsing. I do plan on incorporating bug fixes to the scripting side of the equation to the AE 7 app, so it’ll stay feature compliant to the current state, but I won’t be updating new features.

This will definitely make things a lot easier to develop tools, and it opens up a whole new slew of possibilites for Web 2.0 mashup tools and explorations when combined with After Effects Socket or new HttpConnection support. kuler explorer anyone? If you’re a scripter, you owe it to yourself to check out the ExtendScript Toolkit (ESTK) 2.0 there are a lot of features that sort of “hide” in Extendscript that aren’t obvious in the After Effects CS3 scripting guide(pdf link).

Comments (9)

More fun with sampleImage(): Ascii animation in After Effects

More experimentation with sampleImage(). This one relies on this expression.

target = thisComp.layer("");
samples = new Array();

var spacing = 10;
var w = target.width / spacing ;
var layerOrder = 1;
var h = 10 * layerOrder;

letters = "   .,:!-+=;iot76x0s&8%#@$";

for(x= 0; x < w; x++){
	samples[x] = target.sampleImage([x* spacing ,h],[spacing , spacing], false, time);

var string = '';

for(z = 0; z < samples.length; z++){
	var y = Math.round((0.299 * samples[z][0] + 0.587 * samples[z][1] + 0.114* samples[z][2]) * 100)/ 4;
	string = string + letters.substring(y,y + 1);


We loop through the row of pixels and place the sampled RGB pixels in the samples array, convert the RGB samples to YUV and grab the Y or brightness value for comparison against a rough gradient of ASCII values. For best results, use a monospace font to retain proper spacing. A more complete script/expression and breakdown to come.

Comments (7)

sampleImage() is fun

sampleImage() is a new layer method expression introduced in After Effects CS3 that allows you to access a layer’s color pixel data. Combined with sophisticated particle systems like Particular, I think we’re likely to see some really interesting designer driven explorations a la Processing, but with more of a tinkering, let’s try things out approach.

I’ll have more scripts, and automated stuff as I explore further, but until then you might want to take a look at the reference and examples that Dan Ebberts is posting at the brilliant

Comments (2)

Restricting text entry to a certain number of lines in Actionscript

This one deviates a bit from my usual video workflow stuff, but I’ve been writing a lot of Actionscript and spent too much time researching this topic without a lot of great answers.

It’s surprisingly hard to restrict text entry to a limited number of lines in an input text field in Flash. You can restrict characters, but unless you’re using a monospaced font it can produce inconsistent results and you have to make sure you catch the return and enter keys so that you don’t scroll into oblivion. The following code simply replaces the return and enter key with a space and uses an onChange handler to make sure we don’t exceed maxscroll, which in this case is hard coded at 3 lines. It works pretty well and handles some edge cases like copy/pasting by restricting the paste to just visible characters in the text field.

textEntry.onChanged = function(){
     var symbol:String = "\r";
     var symbolPos:Number = textEntry.text.indexOf(symbol);

     if (symbolPos > -1) {
		textEntry.replaceText(symbolPos, symbolPos + 1, ' ');
	} else {
		//trace("symbol '"+symbol+"' not found.");
	for(i=0; i< textEntry.text.length;  i++){
		textEntry.scroll = textEntry.maxscroll;

		if(textEntry.bottomScroll > 3){
			  textEntry.text = textEntry.text.slice(0, textEntry.text.length-1);


Comments off

Exporting Camera Data from After Effects to Cinema 4D

Paul Tuersley has written a script for exporting camera data from After Effects to Cinema 4D. Paul has also written an extensive brain dump on his process of writing the script and it’s a great example of how research and development of scripts and tools can take on a life of its own. I’ve talked to a couple of people lately who feel that scripting is just beyond their reach, but I hope by reading posts like Paul’s, folks realize that a bit of tenacity and letting a problem gestate and get under your skin until you “just have to solve this” goes a long way to developing really useful tools.

Paul was also kind enough to send me his upgrades and update to my Auto Rig Script for After Effects. I’ve posted his version of the script and I hope to make his changes permanent once I can get some field testing of it working out in all situations. So, I’d appreciate it if you’d download it and give me feedback if you have any issues.

Great work Paul!

UPDATE 04.24.2007

Paul posted a project ( set up to animate the null instead of the camera that will allow the use of motion paths addressed in the comments below. It also sounds like Paul has a lot of ideas about new features and is looking for feedback at the thread he’s set for the script at aenhancers.

UPDATE 06.09.2007
Paul has updated his script to version 1.1

Paul writes…
I’ve posted a new version of that AEtoC4D script that exports normal
AE cameras, and more.

AE to C4D

Comments (9)

Older Posts »