Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects A Script to access Sourcetext

  • A Script to access Sourcetext

    Posted by Erin Shelby on September 27, 2005 at 12:27 am

    Okay, I was doing OK w/ expressions but for some reason scripts have me a bit messed up…

    I’m trying to write a script that accesses:

    -a specific comp,
    -then a specific text layers character length
    -then put this information somewhere else (eg: display this on another text layer, set as x-position of a solid…)

    So if a string had 100 characters, running the script would tell you it had 100 characters in another textlayer, or it could set the position of a solid layer…I know how to do it w/ expressions, but the problem is that the user of the AE file will want to ‘tweak’ the information after – so I don’t want the information continually updated – they can just run the script once and have get a ‘hint’ of the information and tweak afterwards if they want…

    This question is more about basic scripting, accessing specific values (all the example scripts can do fancy things like find a certain string in *all* the text layers of a file, but how do I make it just access a specific comp, specific layer)?

    Sorry if I’m confusing, it’s just I thought the transition to scripts would be easier….

    -echo

    Erin Shelby replied 20 years, 7 months ago 2 Members · 3 Replies
  • 3 Replies
  • Erin Shelby

    September 27, 2005 at 12:36 am

    actually, let me reduce my thought more…

    okay, lets say I have a comp called Bongle and a layer called Dongle…how would I access the sourcetext property of that layer in a project?

  • Dan Ebberts

    September 27, 2005 at 12:46 am

    I haven’t tested this stuff, so there may be errors, but basically it’s like this. Finding a specific comp in the project window is kind of clunky, but you can do it like this:

    var compName = “xxxx”; //comp name goes here
    var myProject = app.project;
    var n = myProject.numItems;
    var foundIt = false;
    var i;
    for (i=1; i<=n; i++){ if (myProject.item(i).name == compName){ var myComp = myProject.item(i); break; } } Finding a layer in a comp is pretty much the way you do it in expressions: var layerName = "yyyy"; //layer name goes here var myLayer = myComp.layer(layerName); Getting the length of a layer's source text would look like this: var mySourceText = myLayer.text.sourceText; var mySourceTextLen = mySourceText.len; Hope that's helpful. Dan

  • Erin Shelby

    September 27, 2005 at 1:00 am

    ah, I believe I understand…
    very much appreciated.

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