Forum Replies Created

Page 23 of 24
  • Scott Mcgee

    April 5, 2017 at 8:25 am in reply to: Listbox .selectedItem, .selection, .??????

    Hey Dan,

    Thanks for the response, but I couldn’t get that too work. I did get another response from the adobe forum with the below. This works, but I forgot the crucially mention that Column 1 is set up from an Array. I managed to fix that aswell, but I can’t seem to get the info I want from column 2.

    //BTN: to apply selected listbox item
    var myBtn = w.add (“button”, undefined, “Apply”);

    myBtn.onClick = function(){

    var myComp = app.project.activeItem; if(!myComp || myComp.typeName !== “Composition”) return;
    var Text1 = myList.selection[0].text;
    var Text2 = “Column 2”
    var textValue = myComp.layer(“”+Text1+””).property(“ADBE Text Properties”).property(“ADBE Text Document”).value;
    textValue.text = Text2;
    myComp.layer(“”+Text1+””).property(“ADBE Text Properties”).property(“ADBE Text Document”).setValue(textValue);
    }

  • Scott Mcgee

    March 29, 2017 at 3:34 pm in reply to: Renaming Solid Layer (Expression or Script)

    I cracked it.

    It’s a dirty way to do it, so if anyone has a tidier way feel free to add.

    So Dan helped me with an expression that looked for a specific slider to +1, but if something went between two layers that didn’t have it. It would break and not work, or the expression would include that layer and add +2 which left me with a gap.

    This expression below, would look passed a layer that didn’t contain the slider and ignore it

    val = null;
    for ( i = index+1; i <= thisComp.numLayers; i++){
    try{
    val = thisComp.layer(i).effect(“bar_index”)(“Slider”).value +1;
    break;
    }catch(err){
    }

    So my .value in my slider would be like this

    1:Bar 5 (5)
    2:Bar 4 (4)
    3: Text 1 (Ignore)
    4: Bar 3 (3)
    5: Bar 2 (2)
    6: Bar 1 (1)

    Now if I delete a layer in the middle and and duplicate I get this, but my expression keeps the value of the slider the same like below.

    1:Bar 7 (5)
    2:Bar 4 (4)
    3: Text 1 (Ignore)
    4: Bar 6 (3)
    5: Bar 2 (2)
    6: Bar 1 (1)

    The problem now is that I need my layers to be sequential for my script to work. Otherwise it’s going to skip my editText box referencing Bar 2 and Bar 5

    So with the help of Dan and mucking I thought to get it to read the slider value to add the number next to it. So below.

    str1 = “Bar”;
    var comp = app.project.activeItem;
    for (var i = 1; i <= comp.numLayers; i++){
    if (comp.layer(i).name.substr(0,str1.length) == str1){
    comp.layer(i).name = str1 +” “+ comp.layer(i).effect(“bar_index”)(“Slider”).value;
    }
    }

    Once fired replaces it all back to

    1:Bar 5 (5)
    2:Bar 4 (4)
    3: Text 1 (Ignore)
    4: Bar 3 (3)
    5: Bar 2 (2)
    6: Bar 1 (1)

    For anyone who is thinking…What on earth would you use this for….A bar graph my dear friend. A bar graph that if someone who doesn’t know after effects can open up my template. Fire up my UI panel and tell it what Bar 1 – 5 values are, it will animate to the correct percentage. Too some of you this is child’s play. For me this was my personal mount everest to get this to work and eventually hand this over to the news team to quickly make a bar graph without needing any after effects knowledge…Woohoo.

    <b>str1 = "Bar";
    var comp = app.project.activeItem;
    for (var i = 1; i &lt;= comp.numLayers; i++){
    if (comp.layer(i).name.substr(0,str1.length) == str1){
    comp.layer(i).name = str1 +" "+ comp.layer(i).effect("bar_index")("Slider").value;
    }
    }</b>

  • Scott Mcgee

    March 29, 2017 at 12:11 pm in reply to: Renaming Solid Layer (Expression or Script)

    I’ve managed to shorten the script as I don’t need str2 as it’s not changing it from bar to something else. it’s just adding a number after

    str1 = “Bar”;
    k = [1,2,3,4,5]
    var comp = app.project.activeItem;
    for (var i = 1; i <= comp.numLayers; i++){
    if (comp.layer(i).name.substr(0,str1.length) == str1)
    comp.layer(i).name = str1 +” “+ k[i-1];
    }

    But i still haven’t got it to start from layer 6 and work it’s way back to layer 1 skipping anything that doesn’t have Bar in it’s title so that the next one in the chain should end up like this.

    1: Bar 5
    2: Bar 4
    3: Text 1
    3: Bar 3
    4: Bar 2
    5: Bar 1

  • Scott Mcgee

    March 29, 2017 at 8:24 am in reply to: Renaming Solid Layer (Expression or Script)

    Hey Dan,

    I’ve combined two of them together, this is nearly what I want.

    comp.layer(i).name = str2 +” “+ k[i-1]

    str1 = “Bar”;
    str2 = “Bar”;
    k = [1,2,3,4]
    var comp = app.project.activeItem;
    for (var i = 1; i <= comp.numLayers; i++){
    if (comp.layer(i).name.substr(0,str1.length) == str1)
    comp.layer(i).name = str2 +” “+ k[i-1];
    }

    I want it to work from the ground up. In my example

    1: Bar 5
    2: Bar 4
    3: Bar 3
    4: Bar 2
    5: Bar 1

    This would work fine, if it is 5 layers, and my array is set [5,4,3,2,1]. I know this works, but if I have 10 layers. It comes up as undefined from layer 6 onwards, which is obvious as to why this happens, as it is looking at the first layer (i = 1) and because I have only 5 numbers in my array it stops after layer 5, how do I get it to work from the ground up?

    So if I had 20 layers, it knows to start from layer 20.

    Then the cherry on top. You wrote me an expression where if a break happens it moves to the next layer not taking the break into account

    val = null;
    for ( i = index+1; i <= thisComp.numLayers; i++){
    try{
    val = thisComp.layer(i).effect(“bar_index”)(“Slider”).value +1;
    break;
    }catch(err){
    }

    I’m happy to write out an array [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15….], because nobody is going to want more than 15. But if you put a text layer in between them I get this.

    1: Bar 1
    2: Bar 2
    3: Text 1
    4: Bar 4
    5: Bar 5
    6: Bar undefined

    I tried adding a break, I tried index +1, but I’m having no success.

    Is it something so simple, i can’t see the forest for the trees.

  • Scott Mcgee

    March 28, 2017 at 9:57 pm in reply to: Renaming Solid Layer (Expression or Script)

    After a few hours of research this script is essentially what I want

    str1 = “Metallic”;
    str2 = “Regent”;
    var comp = app.project.activeItem;
    for (var i = 1; i <= comp.numLayers; i++){
    if (comp.layer(i).name.substr(0,str1.length) == str1)
    comp.layer(i).name = str2 + comp.layer(i).name.substr(str1.length);
    }

    Is there anyway to adapt this to do this,

    str1 = “Bar”;
    str2 = “Bar”;
    k = [1,2,3,4]
    var comp = app.project.activeItem;
    for (var i = 1; i <= comp.numLayers; i++){
    if (comp.layer(i).name.substr(0,str1.length) == str1)
    comp.layer(i).name = str2 + k;
    }

  • Scott Mcgee

    March 20, 2017 at 10:37 pm in reply to: try catch try catch try catch

    As always, you’re a true star.

    3 days trying to figure this out, and you got it in one.

    Thank you Sir

  • Still struggling with this,

    But to update…

    var name = “Bar”;
    for (i =1; i <=thisComp.numLayers; ++i) {
    if(thisComp.layer(i).name){
    i;
    break;
    }
    }

    I thought the expression was referring to the name Bar, but when I deleted this and left it blank. It still worked, which is fine. Except I still have the problem of this

    I want the expression to still +1 my slider, so it shifts the position, but I want it to ignore any layer inbetween so I don’t get the gap.

  • Scott Mcgee

    March 20, 2017 at 12:46 pm in reply to: Spreeder like Text Generator

    https://www.youtube.com/watch?v=a3YZzChyKsg

    This should help you out. I can’t think of an easier way.

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

  • Scott Mcgee

    March 16, 2017 at 9:03 am in reply to: Button that inputs expression from UI Panel

    Thank you very much Dan.

    hahaha, I didn’t see this and literally found something similar you wrote for someone else

    var myEffect = myLayer.Effect.addProperty(“ADBE Slider Control”);
    var myExpr = “amp = effect(1)(“Slider”);” + “r” +
    “freq = effect(2)(“Slider”);” + “r” +
    “x = … etc. ;”;

    myLayer.property(“position”).expression = myExpr;

    So I reworked it to reflect what you’ve put


    applyButton.onClick = function(){
    props = app.project.activeItem.selectedProperties;
    for (var i = 0; i < props.length; i++){
    if (props[i].canSetExpression){
    props[i].expression = “input = thisComp.layer(\”[Colour]\”).text.sourceText; if( (input == \”red\”) == 1) value else 0;”;
    }
    }

    I was going to ask if there was a way to create a textStr in the expression, so you can put your own variable to your layers and click the button and it will add it to all those layers. Found another one of your wonderful threads and came up with this

    applyButton.onClick = function(){
    props = app.project.activeItem.selectedProperties;
    textStr = addScript.text;
    for (var i = 0; i < props.length; i++){ if (props[i].canSetExpression){ props[i].expression = "input = thisComp.layer(\"[Station]\").text.sourceText; if((input == \"" +textStr+ "\") == 1) value else 0;"; } } }

    I’m starting to enjoy this script building malarky.

  • Scott Mcgee

    October 12, 2016 at 1:33 pm in reply to: Color from text.sourceText expression

    Just incase

    I’ve found, after more searching someone else wanted to do the same.

    So if you are struggling with this and not found their forum.

    Dan Ebberts resolved this one. I was so close yet so far… I will get used to this Java talk.

    txt = thisComp.layer(“TEXTCONTROL”).text.sourceText;
    if (txt == “violet”)
    ([.75,0,1,1])
    else if (txt == “blue”)
    ([0,0,1,1])
    else
    [.5,.5,.5,1];

Page 23 of 24

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