Troubleshooting Setting Text Parameters

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
lunelson
Posts: 18
Joined: March 26th, 2006, 1:58 am

Hi there,

I'm trying to make a recursive script to copy the "document" parameters from the first frame of a text layer (or first frame of the work area, alternately), and copy them to all subsequent frames, save for the string. This is a text layer that has a different string at each frame but once you have set KFs in each frame of a text layer there is no longer a global way to change formatting such as alignment or font or spacing etc.

Tried to base it on another recursive scrip that was here, and combining it with Todd Kopriva's blog post about CS4's access to text properties

Problem is it doesn't work. It copies all value to all subsequent frames, including the string.

Any ideas what I'm doing wrong?

Code: Select all

/* 	An attempt to make a script that will read all the text formatting parameters 
	from the first frame and apply them to subsequent frames	
	Assumes we have a text layer selected	*/

var thisComp = app.project.activeItem;
var thisLayer = thisComp.selectedLayers[0];

var workAreaInFrames = thisComp.workAreaDuration*thisComp.frameRate;
var workAreaStartInFrames = thisComp.workAreaStart*thisComp.frameRate;

// set up a variable to reference those parameters
var textDoc = thisLayer.property("ADBE Text Properties").property("ADBE Text Document");
// set up a value equal to those params at time = 0
var textValue = textDoc.valueAtTime(0, true);

for (i=1; i < workAreaInFrames; i++) {

	var myTime = ((workAreaStartInFrames-1) + i) / thisComp.frameRate;
	
	//try to avoid changing the string -- set string portion of textValue with current value
	textValue.string = textDoc.valueAtTime(myTime, true).string;
	
	//set the "document" to the same values as time 0, only with the current string
	textDoc.setValueAtTime(myTime, textValue);
	
	//write the progress to the info window
	writeLn("Processing frame " + i + " out of " + Math.round(workAreaInFrames));
	
	//clear the line after it's written
	clearOutput();
	}//close loop
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

You just need to change this line:

Code: Select all

textValue.string = textDoc.valueAtTime(myTime, true).string;
to:

Code: Select all

textValue.text = textDoc.valueAtTime(myTime, true).text;
Post Reply