FORUMS: list search recent posts

Selecting Empty Source text Keyframe through Expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Johanna Daluz Peterson
Selecting Empty Source text Keyframe through Expression
on Sep 18, 2012 at 9:25:23 pm

Hello!

I'm doing some subtitles and I used a script I found online but the problem is I still need to select all Empty Source Text Keyframes that the script had created the entire subtitles. How do you select these Empty Source Text Keyframes all at once through a script? Its hard to select them manually through each line. I hope somebody could help me find a script to select these so I can just delete them. Thanks for your help!


Return to posts index

Dan Ebberts
Re: Selecting Empty Source text Keyframe through Expression
on Sep 19, 2012 at 2:57:55 am

By empty keyframes, do you mean keyframes where there is no text? If so, something like this should remove those keyframes from the selected text layer:


{
function main(){
var myComp = app.project.activeItem;
if ((myComp == null) || ! (myComp instanceof CompItem)){
alert("No comp selected.");
return;
}
if (myComp.selectedLayers.length == 0){
alert("No layer selected.");
return;
}
var myLayer = myComp.selectedLayers[0];
if (!(myLayer instanceof TextLayer)){
alert("Selected layer is not text layer");
return;
}
var myProp = myLayer.property("Text").property("Source Text");
for (var i = myProp.numKeys; i > 0; i--){
if (myProp.keyValue(i) == ""){
myProp.removeKey(i);
}
}
}
main();
}



Dan



Return to posts index

Johanna Daluz Peterson
Re: Selecting Empty Source text Keyframe through Expression
on Sep 19, 2012 at 3:16:53 pm

Hi Dan,

Thank you for your response! You're right Empty text meaning No Text. I'm not really good at scripting and I might be doing it incorrectly. When I tried saving the code into .jsx and run the script with the selected text layer, it didn't work for me. I'm using AE CS5 in Mac, i'm uncertain if there should be added/changed values in the script to work on Mac or if there are other things I need to do.

This is how I hope it would happen so then I can just delete them all at once.


I appreiate your help. Thanks!

Johanna


Return to posts index


Johanna Daluz Peterson
Re: Selecting Empty Source text Keyframe through Expression
on Sep 19, 2012 at 3:52:57 pm

I probably had a mistake on identifying what's on the Text Layer. It looks like its empty but when I selected that keyframe it had that "blank space" or " " in that keyframes. Can you help me on the script modifications?

Screenshot on the keyframe to delete:

spaceintext-keyframesnotemptytext.png

Thank you !


Return to posts index

Johanna Daluz Peterson
Re: Selecting Empty Source text Keyframe through Expression
on Sep 19, 2012 at 4:16:52 pm

Oh yeah I think I had a lucky guess on the changes on the script. It worked for me :)

here is how I've tried changing them:

{
function main(){
var myComp = app.project.activeItem;
if ((myComp == null) || ! (myComp instanceof CompItem)){
alert("No comp selected.");
return;
}
if (myComp.selectedLayers.length == 0){
alert("No layer selected.");
return;
}
var myLayer = myComp.selectedLayers[0];
if (!(myLayer instanceof TextLayer)){
alert("Selected layer is not text layer");
return;
}
var myProp = myLayer.property("Text").property("Source Text");
for (var i = myProp.numKeys; i > 1; i--){
if (myProp.keyValue(i) == " "){
myProp.removeKey(i);
}
}
}
main();
}


Thanks Dan for the script~! :)

For my last question, how do you modify the script if I wanted to select multiple text layers in the composition and delete these keyframes with space in text layers? THANKS!


Return to posts index

Dan Ebberts
Re: Selecting Empty Source text Keyframe through Expression
on Sep 19, 2012 at 5:44:07 pm

You just need to loop through the selected layers:


{
function main(){
var myComp = app.project.activeItem;
if ((myComp == null) || ! (myComp instanceof CompItem)){
alert("No comp selected.");
return;
}
if (myComp.selectedLayers.length == 0){
alert("No layer selected.");
return;
}
for (var j = 0; j < myComp.selectedLayers.length; j++){
var myLayer = myComp.selectedLayers[j];
if (!(myLayer instanceof TextLayer)){
alert("Selected layer is not text layer");
return;
}
var myProp = myLayer.property("Text").property("Source Text");
for (var i = myProp.numKeys; i > 1; i--){
if (myProp.keyValue(i) == " "){
myProp.removeKey(i);
}
}
}
}
main();
}



Dan



Return to posts index


Johanna Daluz Peterson
Re: Selecting Empty Source text Keyframe through Expression
on Sep 19, 2012 at 6:32:33 pm

Thank you so much Dan!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]