Problem setting a KeyFrame via Script

What type of scripts do you need?

Moderator: byronnash

Post Reply
8bit
Posts: 3
Joined: October 29th, 2007, 10:13 am

Hi everyone

I`ve got a problem by creating a keyframe. The script is a part of a bigger one, reduced to the Problem i have with it.
you have to create a sequence in 25fps first, then you can run the script.

It creates 3 Keyframes
1. at 00:00:00:00 ("")
2. at 00:00:10:00 ("In-Frame")
3. at 00:11:18:10 ("678,4")

my problem ist, that the 3rd. keyframe looks like it is on the correct frame, but you see the change in text 1frame later.
It is not exactly aligned to the frame...
When you do a short click on this keyframes, it aligns exact to the frame, and it changes at the right timecode.

The number displayed at the third keyframe is the frame in seconds.
There should be no rounding-problem, because you can calculate this value to frames and back, and there will be no changes..

This error does appear on a lot of framenumbers, and my keyframes have to be set exactly...

I would be very happy, if someone could help me, solving this problem.

and here`s the script:

Code: Select all

// start of script
var curItem = app.project.activeItem; 
// = 1/25
curItem.frameDuration=0.04;

// frame number, where a keyframe should be set
var input = 16960;

// calls function to create the text layer
createTextLayer();
// calls function to set the keyframe
setTextKeyframes(10,input,"In-Frame");


// creates a text layer

function createTextLayer(){
	curItem.layers.addText("aa");
	curItem.curLayer = curItem.layer("aa"); 
	curItem.curLayer.name="subtitle";
	
	curItem.curLayer.sourceText.setValueAtTime(0, "")
}
//

// sets keyframes with text
function setTextKeyframes(InFrame, OutFrame, Text){	
	var OutEdit =OutFrame * curItem.frameDuration;
	
	curItem.curLayer.sourceText.setValueAtTime(InFrame, Text)
	// displays the calculation Frame to seconds
	curItem.curLayer.sourceText.setValueAtTime(OutEdit,OutEdit)
}
//

//  end
8bit
Posts: 3
Joined: October 29th, 2007, 10:13 am

So,
now a colleague of me found a very simple workaround for this problem.:

Code: Select all

curItem.curLayer.sourceText.setValueAtTime(OutEdit-(curItem.frameDuration/100),OutEdit)
//or
curItem.curLayer.sourceText.setValueAtTime(OutEdit-0.00001,OutEdit) 
Now every keyframe is 1/100 frame, or 1/10000 second too early. That`s not really nice, but the change in text is now at the right time :D .

The Problem are the "floating numbers". So the values are not EXACT, what AE tells you in the output...
Post Reply