script to take a text layer and put each word on own layer?

What type of scripts do you need?

Moderator: byronnash

Post Reply
pants
Posts: 22
Joined: October 8th, 2004, 8:35 am

I have a text layer with a big paragraph of text in it. some of the words are different sizes & colors. Anyone know of a script that could take the 1 layer and then put each word on it's own layer keeping the size/color and position in tact?

Thanks
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

Your best bet might be to just use an opacity animator with a simple expression and duplicate the layer a bunch of times. For example, add an opacity animator, set it to 0%, units = index, based on = words, mode = subtract, start = 0, end = 1. then add this expression to offset:

index -1

Dupicate the layer enough times to make all the words appear. You could, of course, do the same thing with a script if you really needed to automate the process.

Dan
pants
Posts: 22
Joined: October 8th, 2004, 8:35 am

Hey dan,

thanks for the tip. this works. but isn't ideal, cause then i'd need to shift the anchor point manually on each layer to the center of the word. Unless there's another expression or script i could use to do this.


I just found this script on NAB's site. decompose text
http://www.nabscripts.com/Downloads/dow ... 2.php?id=2

it takes word/s and then puts each letter in it's own layer. anyone know if you can modify this to take each word and put it in it's own layer, while retaining color, size and position info?

thanks

Code: Select all

/*

 "decomposeTextLayer.jsx"

    www.nabcripts.com

 

 This script creates a new text layer for each character found in the selected text layer.

*/

 

{





// MAIN SCRIPT  



if (!app.project) 

	alert("Open a project first and select a text layer.");

else { 

	var myComp = app.project.activeItem;

	if (myComp == null || !(myComp instanceof CompItem))

		alert("Select a text layer and run the script again.");

	else {

		if (myComp.selectedLayers.length != 1)

			alert("Select a text layer and run the script again.");

		else {

			var myLayer = myComp.selectedLayers[0];

			

			app.beginUndoGroup("deconposeTextLayer.jsx");

			

			if (myLayer.sourceText != null) {

				var myText = myLayer.sourceText.value.toString();

				var L = myText.length;

				for (var i = 0; i < L; i++) {

					var curLetter = myText[i];

					if (curLetter != " ") {

						var newTextLayer = myLayer.duplicate();

						newTextLayer.sourceText.setValue(curLetter);

					}

				}

			}

			else 

				alert("Select a text layer and run the script again.");

			

			myLayer.enabled = false;

			myLayer.selected = false;

			

			app.endUndoGroup();

		}

	}

}





}
Post Reply