Forum Replies Created

Page 62 of 1081
  • I found this one on stackoverflow:

    function calculate_age(birth_month,birth_day,birth_year)
    {
    today_date = new Date();
    today_year = today_date.getFullYear();
    today_month = today_date.getMonth();
    today_day = today_date.getDate();
    age = today_year - birth_year;
    if ( today_month < (birth_month - 1))
    {
    age--;
    }
    if (((birth_month - 1) == today_month) && (today_day < birth_day))
    {
    age--;
    }
    return age;
    }
  • Dan Ebberts

    January 4, 2023 at 8:50 am in reply to: Control 2nd keyframe with slider

    Yes, you can add an expression to a keyframed property, but the expression has to supply the property’s value at all frames, not just at a particular keyframe. You might be able to achieve the desired result, especially if the keyframes are linear, or you’re willing to accept the easing provided by ease(), easeIn(), or easeOut() expressions. However, it gets trickier if you need to preserve some custom easing.

  • Dan Ebberts

    January 2, 2023 at 7:15 pm in reply to: How to script a bounce using layer in point ?

    While I guess it’s possible, this particular expression probably wouldn’t be a good candidate for inputs controlling the total distance traveled. Based on those entries and given values for launch angle, elasticity, gravity, friction, and number of bounces, you could calculate the launch velocity required to give you that result, but it would be messy.

  • Dan Ebberts

    December 28, 2022 at 9:50 pm in reply to: Match Properties Selection

    Thanks for the kind words! I appreciate it.

  • Dan Ebberts

    December 28, 2022 at 7:04 pm in reply to: Match Properties Selection

    To do that, I think you have to build the property spec path on the fly, like this:

    var myComp = app.project.activeItem;
    var myProps = myComp.selectedProperties;
    for (var p = 0; p < myProps.length; p++){
    var myLayers = myComp.selectedLayers;
    for (var l = 0; l < myLayers.length; l++){
    var myProp = myProps[p];
    var myPropString = "";
    while (myProp.parentProperty !== null){
    var name = "\"" + myProp.name + "\"";
    myPropString = ".property" + "(" + name + ")" + myPropString;
    myProp = myProp.parentProperty;
    }
    if (myPropString != ""){
    eval("var myActualProp = myComp.layer('" + myLayers[l].name + "')" + myPropString + ";");
    myActualProp.selected = true;
    }
    }
    };
  • Dan Ebberts

    December 27, 2022 at 10:24 pm in reply to: Iterate script for all selected layers?

    I’m not sure, but if you’re planning on looping this through multiple layers, I think you first need to save the state of which layers and properties are currently selected, because the actions of your function will change that. So you’d need to restore those selections each time through the loop, or change the function to expect layer names and property path specs. It could be tricky, and a little messy.

  • Dan Ebberts

    December 25, 2022 at 1:57 am in reply to: Moving a property using script

    Good point. Are you making sure in your loop that only the property you want to move is selected? It seems like you could get cascading mess if you’re not really tidy about that.

  • Dan Ebberts

    December 24, 2022 at 11:27 pm in reply to: Moving a property using script

    Have you considered using .moveTo() instead of executeCommand() ?

  • sourceRectAtTime() won’t detect the zero-alpha areas of precomp layers.

    You could always convert the anchor point expression to keyframes. That might help.

Page 62 of 1081

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