Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

Bag with getting keyValue

Explorer ,
Oct 07, 2024 Oct 07, 2024

I'm sure, that it is a bag, but if not, help me.

I'm trying to get sourceText keyValues
My code works perfectly, untill i move my text layer in timeline.
When i do, (when layer's startTime not at the start of comp), the keyValues is offseting!
For example, here is the text in keys (the text = frames) "0, 10, 20, 30"
If I shift layer by 10 frames forward, the result be "10, 20, 30, 30"
If shift 10 frames backward, - "0, 0, 10, 20"

How to fix it? Without offseting the layer to get the right value of course.

try{
	var comp = app.project.activeItem;
	
	var sourceTextProp = comp.layer(1).property("ADBE Text Properties").property("ADBE Text Document");
	var textContent = "";
				
	if (sourceTextProp.numKeys > 0) {
		
		for (var k = 1; k <= sourceTextProp.numKeys; k++) {
				
			var textDocument = sourceTextProp.keyValue(k);
			textContent += textDocument.text + " ";
			
		}
		alert(textContent);
	}
	
} catch(err) {alert(err.toString + "\n" + err.line)}

 

TOPICS
FAQ , How to , Scripting
115
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Oct 07, 2024 Oct 07, 2024

Yes, it's a bag.

 

try this:

try{
    var comp = app.project.activeItem;
    var sourceTextProp = comp.layer(1).property("ADBE Text Properties").property("ADBE Text Document");
    // store the startTime;
    var startTime = comp.layer(1).startTime;
    // set the startTime to 0;
    comp.layer(1).startTime = 0;
    var textContent = "";
    if (sourceTextProp.numKeys > 0) {
        for (var k = 1; k <= sourceTextProp.numKeys; k++) {
            var textDocument = sourceTextProp.keyValue(k);
      
...
Translate
Advocate ,
Oct 07, 2024 Oct 07, 2024
LATEST

Yes, it's a bag.

 

try this:

try{
    var comp = app.project.activeItem;
    var sourceTextProp = comp.layer(1).property("ADBE Text Properties").property("ADBE Text Document");
    // store the startTime;
    var startTime = comp.layer(1).startTime;
    // set the startTime to 0;
    comp.layer(1).startTime = 0;
    var textContent = "";
    if (sourceTextProp.numKeys > 0) {
        for (var k = 1; k <= sourceTextProp.numKeys; k++) {
            var textDocument = sourceTextProp.keyValue(k);
            textContent += textDocument.text + " ";
        }
        // restore the startTime
        comp.layer(1).startTime = startTime;
        alert(textContent);
    }
}
catch(err) {
    alert(err.toString + "\n" + err.line)}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines