Forum Replies Created

Page 7 of 32
  • Xavier Gomez

    September 22, 2016 at 12:40 pm in reply to: Limit movement to Comp dimensions

    An expression can bypass the value as you did, but cannot prevent you to set a given value.
    I dont think there is a way to do what you want.

    Note: you could shorten the expression, and make it valid for any comp size, as follows:

    pos = value;
    pos[0] = clamp(pos[0], 0, thisComp.width);
    pos;

    Xavier

  • Xavier Gomez

    September 22, 2016 at 7:41 am in reply to: Finding color property of a shape layer.

    To scout a shape layer, you can use a generic recursive function like the one below:

    function recurseShape(g, groupHandler){
    // g shape layer or group inside a shape ( should have a content property )
    // groupHandler : what do do with each group

    if (!g.content) return; // doesnt apply

    groupHandler(g);

    if (!g.content.property("ADBE Vector Group")) return;

    for (var n=1; n<=g.content.numProperties; n++){
    if (g.content.property(n).matchName==="ADBE Vector Group") recurseShape(g.content.property(n), groupHandler);
    };
    };

    The argument ‘groupHandler’ is itself a function and tells what to do with the immediate content of the shape layer or group inside it.
    In case the ‘thing to do’ is remove or reorganize children, it should be written in a way no error is thrown (!)
    For instance, to change fills to gradient fills, it could be:

    function myGroupHandler_changeFillToGFill(g){
    // g shape layer or group inside a shape ( should have a content property )

    if (!g.content || !g.content.property("ADBE Vector Graphic - Fill")) return;

    for (var n=1; n<=g.content.numProperties; n++){
    if (g.content.property(n).matchName==="ADBE Vector Graphic - Fill"){
    g.content.property(n).remove();
    g.content.addProperty("ADBE Vector Graphic - G-Fill").moveTo(n);
    };
    };
    };

    And apply this way:

    var comp = app.project.activeItem;
    app.beginUndoGroup("Change Fills to G-Fills");
    recurseShape(comp.layer(1), myGroupHandler_changeFillToGFill);
    app.endUndoGroup();

    That’s one way to do, you can rewrite your own, but hopefully you get the spirit.

    Xavier

  • Xavier Gomez

    September 21, 2016 at 6:43 am in reply to: Undertanding property speed

    If the leading gear is driven by a speed slider, you should use for that gear an expression as explained in Dan’s website https://motionscript.com/articles/speed-control.html

    For all other gears, i think that the expression i posted will work.

    For these gears, you dont need a “inverse” checkbox, since a gear necesserily rotates the way opposite to its “parent”.
    And the expression for these gears should not mention a “speed” variable either, otherwise you’ll need to integrate that speed, which can be super slow, and not necessary. (Overall, the rotation variation is a multiple of the rotation variation of the leader rotation, and that multiple is only determined by size ratios).

    Xavier

  • Xavier Gomez

    September 19, 2016 at 6:08 pm in reply to: rgb hsl – adjusting saturation via expression

    You can normalize your slider the way you want. It only changes the slider usable range.
    In the end, the 3 numbers, h, s and l that you input in hslToRgb([h,s,l]) should all be in the range [0,1].
    If not, AE will clamp to [0,1].
    0 <==> 0% saturation
    1<==> 100% saturation
    Similarly for Lightness, and Hue is mapped from [0,1] to [0,360].

    But it’s unclear whether you want to set or offset the color lightness (or saturation).

    To set the lighness:

    rgb = thisComp.layer(“MainColor”).content(“Group 1”).content(“Fill 1”).color;
    hsl = rgbToHsl(rgb);
    lite = effect(“liteSlider”)(“Slider”)/100;
    hsl[1] = lite;
    hslToRgb(hsl);

    Then set the slider value to 50, or 33 to have a lightness equal to 50% (or 33%);
    And to offset, by say 5%, you would replace hsl[1] = lite by hsl[1] += lite, and set the slider value to 5.

    Xavier

  • Xavier Gomez

    September 19, 2016 at 3:44 pm in reply to: Undertanding property speed

    Hum, just realized that the expression works because i didnt put a Layer Control on the leading gear.
    If you put one, you’ll get an infinite loop and a time out error.
    It would be better to change the break condition to :

    while(driver!=null && driver.name!==curLayer.name)

  • Xavier Gomez

    September 19, 2016 at 3:40 pm in reply to: Undertanding property speed

    Hi Miguel,
    i tried and observed the same starting from third child.
    It seems that AE needs some guiding otherwise it gets lost.
    This expression seems to work fine:

    curLayer = thisLayer;
    multiplier = 1;
    n=0;
    do{
    try {
    driver = curLayer.effect("Driver")("Layer");
    multiplier *= - driver.name.split("_")[1]/curLayer.name.split("_")[1];
    curLayer = driver;
    ++n;
    }
    catch(e){driver = null;};
    }while(driver!=null);
    if (n===0) value else {
    leadRot = curLayer.rotation;
    thisLayer.rotation.valueAtTime(inPoint)-leadRot.valueAtTime(inPoint) + multiplier* (leadRot.value-leadRot.valueAtTime(inPoint));
    };

    Xavier

    Xavier

  • Xavier Gomez

    September 17, 2016 at 9:29 am in reply to: onActivate , onDeactivate infinite loop problem.

    If you put something that will deactivate the window on its onActivate callback…

    Xavier

  • Xavier Gomez

    September 14, 2016 at 6:35 am in reply to: How to close a ScriptUI element?

    Use the .remove method of the parent (here the window itself) of the element to remove (the button):

    theParent.remove(theChild)
    or
    theParent.remove(theChildIndex) (theChildIndex is an integer in the range [0, theParent.children.length-1])

    btn.onClick = function(){
    this.parent.remove(this);
    myWin.layout.layout(true);
    myWin.layout.resize();
    };

    Xavier

  • Try replace thisComp.layer(pathLayer) by simply: pathLayer

    Not sure it will be compatible with the script’s expression, but it should at least fix the error.

    Xavier

  • Xavier Gomez

    September 1, 2016 at 10:49 pm in reply to: Scientific Notation

    Given how big your end number is, you can try cheating a bit: count up to 1000 only, and fill the rest with random digits. Over only 5 seconds, nobody can see anything.

    startTime = 0; //seconds
    endTime = 5; //seconds
    beginCount = 0;
    endCount = 1e21;
    hasCommas = true;

    //--dont modify below here----------------
    function addCommas ( s ){
    if( s.length <= 3 )
    return s;
    else
    return s.substring(0 , 3) + "," + addCommas(s.substring(3, s.length));

    }
    function reverse( s ){
    newStr = "";
    for(i = s.length-1; i >= 0; i--)
    newStr += s.charAt(i)
    return newStr;
    }

    // count up to 1000
    val = Math.round (linear(time, startTime, endTime, beginCount, 1000) );
    val = val.toString();

    // this part adds some random queue up to 21 digits
    if (startTime

    Xavier

Page 7 of 32

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