Forum Replies Created

Page 106 of 1081
  • Dan Ebberts

    October 13, 2021 at 11:09 pm in reply to: How area texts are pushed into a new line?

    I don’t know that there’s a way to do it based on characters, but it seems like you could compare sourceRectAtTime(time).height to the font size to see if there’s more than one line.

  • Just as a quick demo, create a null named “Control” with a Slider Control and keep this layer at the bottom of your layer stack (below your 27 layers). Add this expression to the slider:

    n = 27;

    period = 1;

    seg = Math.floor(time/period);

    seedRandom(seg,true);

    Math.floor(random(n)) + 1;

    This will broadcast an integer between 1 and 27 for the other layers to use to decide whether to fade up or not. Apply this opacity expression to your 27 layers:

    period = 1;

    fadeTime = .25;

    t = time%period;

    targetLayer = thisComp.layer("Control").effect("Slider Control")("Slider");

    if (targetLayer == index){

    if (t < fadeTime)

    ease(t,0,fadeTime,0,100)

    else

    ease(t,fadeTime,fadeTime*2,100,0);

    }else

    0

    Adjust the period and fadeTime (fadeTime should be half the period, or less).

  • Try it this way:

    n = thisComp.layer("% P&L").effect("Slider Control")("Slider");

    sign = n < 0 ? "-" : "";

    num = sign + "$"+ (Math.abs(n)*10000000).toFixed(0);

    function addCommas(x) {

    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");

    }

    addCommas(num)

  • Dan Ebberts

    October 12, 2021 at 5:23 pm in reply to: Source Text Expressions

    I haven’t tested this, but I think you just need to save your text in a variable and then use .setText() at the end of your expression, like this:

    l = text.sourceText.length;

    if (l>25) {

    txt = "MAX LENGTH EXCEEDED"

    } else {

    txt = text.sourceText;

    }

    var array=[

    "Worker-ExtraBold",

    "Worker-Regular",

    ]

    text.sourceText.style

    .setFontSize(thisComp.layer("CTRL").effect("Font Size")("Slider"))

    .setFont(array[thisComp.layer("CTRL").effect("Font Select")("Slider")])

    .setText(txt)

  • Dan Ebberts

    October 8, 2021 at 8:44 pm in reply to: Display array in text source

    Hard to say what’s wrong without seeing your project. The expression did work for me when I set it up though.

  • Dan Ebberts

    October 8, 2021 at 1:22 pm in reply to: Autoscale multiple lines of text.

    Try this:

    text1width = thisComp.layer("Text 1").sourceRectAtTime(t=50).width;

    text2width = thisComp.layer("Text 2").sourceRectAtTime(t=50).width;

    text3width = thisComp.layer("Text 3").sourceRectAtTime(t=50).width;

    text4width = thisComp.layer("Text 4").sourceRectAtTime(t=50).width;

    text5width = thisComp.layer("Text 5").sourceRectAtTime(t=50).width;

    Max = thisComp.layer("CONTROLS").effect("Text Max Width")(1);

    textWidthMax = Math.max(text1width,text2width,text3width,text4width,text5width);

    NW = (textWidthMax > Max) ? (Max/textWidthMax)*100 : 100;

    [NW,NW]

  • Dan Ebberts

    October 8, 2021 at 12:51 pm in reply to: Display array in text source

    Ah, OK. Each of your points layers would need an expression something like this:

    txt = thisComp.layer("text with all data").text.sourceText;

    myIdx = parseInt(name.split("_")[1],10)-1;

    eval(txt)[myIdx]

    This assumes that the points layer’s name is in the format you’ve shown: “team.points_n”, where “n” minus 1 becomes the index into the array.

  • Dan Ebberts

    October 7, 2021 at 9:49 pm in reply to: Display array in text source

    I’m not sure at all if this is what you’re asking, but if you want a layer’s visibility to be driven by an array, you could use an opacity expression like this:

    array = [75, 60, 40];

    array.indexOf(index) > -1 ? 100 : 0

    and then only layers 40, 60, and 75 would be visible. (Note that this requires the JavaScript expression engine).

    If that’s not what you’re after, please provide more detail.

  • Dan Ebberts

    October 6, 2021 at 6:16 pm in reply to: Does anyone know how Ray Dynamic Color works?

    What’s changing is the value[2] part. If you turn off the expression and put your cursor over the layer, in the Info panel you see that the value of the blue channel changes, depending on the swatch selected. Even though it appears black, there is data embedded in the blue channel.

  • It’s possible if all you’re interested in is the very specific case you mention: the script checks to see if the Blur Radius property is selected, and if so, builds an expression to that property and applies it to the Master Control layer’s Blur Amount slider. However, it gets a lot more complicated in a hurry if you’re looking for a general solution that has to figure out which control on the Master Control layer gets the expression, based on what type of property is selected, or if the selected property might be something other than Fast Box Blur’s Blur Radius.

    Assuming that your goal is just the specific case you mentioned it might look like this:

    var myComp = app.project.activeItem;

    var myProps = myComp.selectedProperties;

    var myLayer = null;

    for (var i = 0; i < myProps.length; i++){

    if (myProps[i].propertyType == PropertyType.PROPERTY && myProps[i].name == "Blur Radius" && myProps[i].parentProperty.name == "Fast Box Blur"){

    myLayer = myProps[i].parentProperty;

    while (myLayer.parentProperty != null){

    myLayer = myLayer.parentProperty;

    }

    var myExpr = 'thisComp.layer("' + myLayer.name + '")("Effects")("Fast Box Blur")("Blur Radius")';

    myComp.layer("Master Control").property("Effects").property("Blur Amount").property("Slider").expression = myExpr;

    break;

    }

    }

    But as I mentioned, anything more general this, while certainly possible, gets messy in a hurry.

Page 106 of 1081

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