Forum Replies Created

Page 3 of 32
  • Name or index will work, take the one that is most suited to your needs.
    It works this way:

    var myFx1 = myLayer.effect.addProperty(matchName1);
    var idx1 = myFx1.name;
    var idx1 = myFx1.propertyIndex;
    var myFx2 = myLayer.effect.addProperty(matchName2);

    // at this stage, the variable myFx1 point to an invalid object

    myLayer.effect.property(matchName1); // the first effect in effect stack that has the same matchName
    myLayer.effect.property(name1); // the first effect in effect stack that has the same name
    myLayer.effect.property(idx1); // should point to the same property as myFx1

    Xavier

  • In previous post i was only looking at the expression code, but.. just thinking now: when expressions break, there is no such message as “Object is invalid”, hence i suppose that you get the error inside your script, not later in after effects.

    Therefore it might be coming from your “other code”.
    And it be so if ‘other code’ messes up with the effects stacks in copyLayer (for instance, if other effects are added, then the copyBlur variable point to a property that is no longer valid, and you have to redefine it).

    Xavier

  • It looks ok, unless the selectedLayers[0] does not have a Slider Control named “Blur”.

    Xavier

  • For properties, there is no moveBefore/moveAfter method, it is:

    myProperty.moveTo(newPropertyIndex).

    var trimPaths = app.project.activeItem.layer(2)(“Contents”)(“B”)(“Contents”).addProperty(“ADBE Vector Filter – Trim”);
    var mergePaths = app.project.item(19).layer(2)(“Contents”)(“B”)(“Contents”)(“Merge Paths 1”);
    trimPaths.moveTo(mergePaths.propertyIndex);

    Xavier

  • Yes you’re right for both.
    The “;” come from the auto-formatting from the browser (i tried to fix but failed).
    And idxB = B.nearestKeyIndex(tB); should indeed be:

    idxB = B.nearestKeyIndex(tA);

    I havent tried to check whether it works or not. It should, be can be slow if many keyframes.
    Your way, collecting keyframes first and compare afterwards, should be faster in that case.

    Xavier

  • There is a misprint inside the secondary loop, it should be: if (t == BKeyTimes[i]) { (==, not =).

    Additionnaly, the loop logic isnt very good: as it is now, it will remove a keyframe on A as soon as that keyframe’s time doesnt match ALL keyframes times on B, which is impossible except in rare situations (only one key on B).
    You’d rather want to keep the key on A if its time matches ONE key time on B, and remove otherwise.

    Here is another approach, simpler to write down, but which might be slow if many keyframes, because of the use of nearestKeyIndex:

    function sameTimes(t1, t2){
    return Math.abs(t2-t1)<;=0.0005;
    };
    function removeAllKeys(prop){
    while(prop.numKeys>0) prop.removeKey(prop.numKeys);
    };

    function removeKeys(A, B){
    if (B.numKeys===0) return removeAllKeys(A);
    var idxA, idxB, tA, tB;
    for (idxA=A.numKeys; idxA>0; idxA--){
    tA = A.keyTime(idxA);
    idxB = B.nearestKeyIndex(tB);
    tB = B.keyTime(idxB);
    if (!sameTimes(tA, tB)) A.removeKey(idxA);
    };
    };

    Xavier

  • Xavier Gomez

    March 13, 2017 at 9:02 pm in reply to: simplify a whole array of expressions

    Your expression is 5 lines long, it cant really be much shorter.
    With a looop can achieve less text though:

    z=0;
    for (i=1; i<6; i++){
    L = thisComp.layer(index+i);
    z += linear(L.transform.scale[1],0,100,transform.yPosition,transform.yPosition-L.content("Rectangle 1").content("Rectangle Path 1").size[1]);
    };
    z;

    You have to specify other layers either by their name, either by their index though.
    There is no such thing as “thisComp.activeLayers”.

    Xavier

  • Normally it should work. Maybe check your syntax.
    I just tried and it worked for me:

    var comp = app.project.activeItem;
    var mattefx = comp.layer(1).effect(1);
    var matteLayer = comp.layer(“Matte”);
    fx(1).setValue(matteLayer.index);

    (setting a value of 0 will set the matte to “None”).

    Xavier

  • What you have tried works for me, and so do any of these:

    var cache = myLayer.effect.addProperty(“ADBE Set Matte2”);

    cache.property(“Invert Matte”).setValue(1);
    cache.property(3).setValue(1);
    cache.property(“ADBE Set Matte2-0003”).setValue(1);

    you can access the matchName of a property like this:
    cache.property(1).matchName; // gives “ADBE Set Matte2-0001”

    Xavier

  • Xavier Gomez

    February 18, 2017 at 2:59 pm in reply to: How to setValue to Trapcode particular size over life?

    Shot in the dark as i dont have particular:
    Reading your description of the parameter (dropdown), you could try setting the value as an integer (1 for first choice, 2 for 2nd choice, etc):

    myProperty.setValue(2);

    (For dropdown properties, the string is only a display info, what counts internally is the index of the menu item).

    Xavier

Page 3 of 32

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