Page 1 of 1

Convert all layers to editable text

Posted: March 17th, 2008, 1:17 am
by brihan
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.

Re: Convert all layers to editable text

Posted: March 17th, 2008, 11:24 am
by lloydalvarez

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;
}

Re: Convert all layers to editable text

Posted: March 18th, 2008, 7:44 pm
by brihan
That's cool. Thanks for that.

Here's hoping for the other half of my request.

Re: Convert all layers to editable text

Posted: March 20th, 2008, 12:51 pm
by Paul Tuersley
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;
			}	
		}
	}
	
}

Re: Convert all layers to editable text

Posted: December 12th, 2012, 3:40 am
by Edu-im
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.