Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change text properties using ExtendScript

  • Change text properties using ExtendScript

    Posted by George Beridze on January 16, 2024 at 2:22 am

    Hey guys,

    I know this is an expressions forum category and I have a question about Extendscript, but maybe I can still post about it?

    So, I’m trying to change one of the text properties here.

    I can successfully change Anchor Point Grouping (see here), using the code below:

    var thisComp = app.project.activeItem;
    var curLayer = thisComp.selectedLayers[0];
    textAnchorPointGrouping = curLayer.property("Text").property("More Options").property("Anchor Point Grouping");
    textAnchorPointGrouping.setValue(1);

    But, when I want to change Based On (see here) property under Range Selector, it’s not working and i’m getting undefined is not an object error (see here). Below is the code:

    var thisComp = app.project.activeItem;
    var curLayer = thisComp.selectedLayers[0];
    textAnchorPointGrouping = curLayer.property("Text").property("Animator 1").property("Range Selector 1").property("Advanced").property("Based On");
    textAnchorPointGrouping.setValue(1);

    Not sure what I’m doing wrong and any suggestions would be helpful!

    Thanks!

    Brie Clayton replied 1 year ago 3 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    January 16, 2024 at 3:27 am

    Try changing the 3rd line to this:

    textAnchorPointGrouping = curLayer.property("Text").property("Animators").property("Animator 1").property("Selectors").property("Range Selector 1").property("Advanced").property("Based On"); 
  • George Beridze

    January 16, 2024 at 3:46 am

    Legend!

    Works perfectly – You just saved me a lot of hours of manual work.

    One more question, please:

    If I have several layers selected (layers are duplicates of each other, each one has the same exact names on text animators), the code doesn’t work on all selected layers – it only works on the first selected layer, not the rest.

    How would I fix that?

  • Dan Ebberts

    January 16, 2024 at 4:44 am

    Try it this way:

    var thisComp = app.project.activeItem;
    var selectedLayers = thisComp.selectedLayers;
    for (var i = 0; i < selectedLayers.length; i++){
    textAnchorPointGrouping = selectedLayers[i].property("Text").property("Animators").property("Animator 1").property("Selectors").property("Range Selector 1").property("Advanced").property("Based On");
    textAnchorPointGrouping.setValue(1);
    }
  • George Beridze

    January 16, 2024 at 5:25 am

    Here I’m getting “null is not an object” error on textAnchorPointGrouping, here’s what’s happening

  • Dan Ebberts

    January 16, 2024 at 7:44 am

    My guess would be that one of your selected layers doesn’t have the same Animator setup as the others, so that the property spec selectedLayers[i].property(“Text”).property(“Animators”)…. doesn’t actually exist.

  • Brie Clayton

    January 16, 2024 at 2:31 pm

    Thank you for solving this, Dan!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy