Convert all layers to editable text

What type of scripts do you need?

Moderator: byronnash

Post Reply
brihan
Posts: 2
Joined: March 16th, 2008, 8:59 pm

Hi there,
My first post on this forum. Looks like lots of great scripts here to play with. Big thanks to all those who share this stuff for free.

I have been googling for a way to convert all my psd layers in a project to convertable text. I have lots of imported psds meaning that all the layers are distributed in hundreds of comp files. It's been pretty monotonous work opening each comp individually and converting them all manually.

Be great if there were a way to change the background color of multiple comps at the same time (so that black text is readable) too.

Thanks.
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Code: Select all

// Comp BG Color setter
//
// Sets the BG color of the selected comps in the project panel to the value defined in bkgColor below.
//
//

var bkgColor = [0,0,0];  // <--- ENTER BG COLOR IN FLOAT VALUES:  for reference Black is 0,0,0 and White is 1,1,1

// begin main script
var myProj= app.project;
for(var i = 1; i <= myProj.numItems; i++){
if (myProj.item(i) instanceof CompItem) myProj.item(i).bgColor = bkgColor;
}
brihan
Posts: 2
Joined: March 16th, 2008, 8:59 pm

That's cool. Thanks for that.

Here's hoping for the other half of my request.
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

brihan wrote:Here's hoping for the other half of my request.
I don't think it's going to be possible to convert the text. This is the only solution I could think of, but unfortunately it only works if you have a comp open and it only works on that comp.

Code: Select all

{
	// Comp BG Color setter
	//
	// Sets the BG color of the selected comps in the project panel to the value defined in bkgColor below.
	//
	//

	var bkgColor = [0,0,0];  // <--- ENTER BG COLOR IN FLOAT VALUES:  for reference Black is 0,0,0 and White is 1,1,1

	// begin main script
	var myProj = app.project;
	// loop through each item in the project window, looking for any comps
	for(var i = 1; i <= myProj.numItems; i++){
		if (myProj.item(i) instanceof CompItem) {
			//set background color
			myProj.item(i).bgColor = bkgColor;

			//loop through all layers, selecting them
			for (var j = 1; j <= myProj.item(i).numLayers; j++) {
				myProj.item(i).layer(j).selected = true;
			}
			// try the "Convert Text" menu command. catch the error if there were no layers to convert
			try {
				app.executeCommand(app.findMenuCommandId("Convert to Editable Text"));
			} catch(e) {
			}
			// loop through the layers in this comp, deselecting them
			for (var j = 1; j <= myProj.item(i).numLayers; j++) {
				myProj.item(i).layer(j).selected = false;
			}	
		}
	}
	
}
Edu-im
Posts: 5
Joined: September 28th, 2011, 10:59 am

I've been working on a similar script as a part of a bigger one. I've seen in new CS6 scripting guide that there's a new function: compItem.openInViewer(). Unfortunately, I use CS5, so I cannot try it. My question is if it is possible to use openInViewer() to make Paul Tuersley's script work? Just make AE open each comp before applying executeCommand().

Edu Iglesias

PS: My own piece of code is quite similar to the shown above, so if it works for Paul, it will work for me.
Post Reply