Forum Replies Created

Page 74 of 1081
  • Dan Ebberts

    October 10, 2022 at 6:43 pm in reply to: Delete layer marker with specific comment

    I was surprised to find that removeKey() doesn’t accept markerComment as an index, so I guess you have to do it the brute force way:

    var myProp = app.project.activeItem.layer(1).property("Marker");
    for (var i = 1; i <= myProp.numKeys; i++){
    if (myProp.keyValue(i).comment == "test"){
    myProp.removeKey(i);
    break;
    }
    }
  • Dan Ebberts

    October 9, 2022 at 12:06 am in reply to: Expression to Keyframes on specific property

    This should work:

    var myComp = app.project.activeItem;
    var myLayers = myComp.selectedLayers;
    if (myLayers.length > 0){
    var myLayer = myLayers[0];
    for (var i = 0; i < myLayers.length; i++){
    myLayers[i].selected = false;
    }
    myProp = myLayer.effect("Faux Parent")("Position Offset");
    myProp.selected = true;
    app.executeCommand(app.findMenuCommandId("Convert Expression to Keyframes"));
    }
  • Dan Ebberts

    October 8, 2022 at 5:18 pm in reply to: Move CTI to Home and Back

    Like this, I guess:

    var myComp = app.project.activeItem;
    var saveCTI = myComp.time;
    myComp.time = 0;
    // do stuff
    myComp.time = saveCTI
  • Dan Ebberts

    October 8, 2022 at 4:50 pm in reply to: Expression to hold animation

    Something like this, maybe:

    f = fAccum = 0;
    while (f < timeToFrames(time)){
    if (opacity.valueAtTime(framesToTime(f)) > 0) fAccum++;
    f++;
    }
    valueAtTime(framesToTime(fAccum))
  • Dan Ebberts

    October 7, 2022 at 7:22 pm in reply to: Change dot to comma in expression

    I think I’d do it this way:

    function Comma(number,sep) {
    number = '' + Math.round(number);
    if (number.length > 3) {
    var mod = number.length % 3;
    var output = (mod > 0 ? (number.substring(0,mod)) : '');
    for (i=0 ; i < Math.floor(number.length / 3); i++) {
    if ((mod == 0) && (i == 0))
    output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
    else
    output+= sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
    }
    return (output);
    }
    else return number;
    }
    var num = Math.floor(effect("Number")("Valor").value);
    var menu = effect("Number")("Dot and Comma").value;
    switch (menu){
    case 3:
    case 4:
    var mySep = ",";
    break;
    case 5:
    var mySep = "_";
    break;
    case 6:
    var mySep = " ";
    break;
    default:
    mySep = "."
    break;
    }
    num = Comma(num,mySep);
  • Dan Ebberts

    October 7, 2022 at 5:35 pm in reply to: Change dot to comma in expression

    There’s another one in there. I still haven’t been able to completely test this because of your effect names, but I can test everything but those two lines and I think this works now:

    function Comma(number,sep) {
    number = '' + Math.round(number);
    if (number.length > 3) {
    var mod = number.length % 3;
    var output = (mod > 0 ? (number.substring(0,mod)) : '');
    for (i=0 ; i < Math.floor(number.length / 3); i++) {
    if ((mod == 0) && (i == 0))
    output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
    else
    output+= sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
    }
    return (output);
    }
    else return number;
    }
    var num = Math.floor(effect("Number")("Valor").value);
    var menu = effect("Number")("Dot and Comma").value;
    var mySep = menu == 3 || menu == 4 ? "," : ".";
    num = Comma(num,mySep);
  • Dan Ebberts

    October 7, 2022 at 5:28 pm in reply to: Change dot to comma in expression

    Sorry. Line 2 should probably be like this:

    number = '' + Math.round(number);

    There may be others that I didn’t catch from when you posted your original expression without using the </> formatting.

  • Dan Ebberts

    October 7, 2022 at 4:11 pm in reply to: Error when using toWorldVec when scale is 0

    I’m guessing the math behind toWorldVec just doesn’t work if scale is zero. So at that point maybe rotation has no meaning? I’m not sure.

  • Dan Ebberts

    October 7, 2022 at 3:44 pm in reply to: Change dot to comma in expression

    I haven’t test this, but it should be close:

    function Comma(number,sep) {
    number = " + Math.round(number);
    if (number.length > 3) {
    var mod = number.length % 3;
    var output = (mod > 0 ? (number.substring(0,mod)) : ");
    for (i=0 ; i < Math.floor(number.length / 3); i++) {
    if ((mod == 0) && (i == 0))
    output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
    else
    output+= sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
    }
    return (output);
    }
    else return number;
    }
    var num = Math.floor(effect("Number")("Valor").value);
    var menu = effect("Number")("Dot and Comma").value;
    var mySep = menu == 3 || menu == 4 ? "," : ".";
    num = Comma(num,mySep);
  • Dan Ebberts

    October 7, 2022 at 2:25 pm in reply to: Error when using toWorldVec when scale is 0

    Possibly, depending on what you want to happen. You could encase the toWorldVec() in a try/catch clause, but then you have to decide what you want the result to be in that case:

    try{
    thisComp.layer(2).toWorldVec([1,0,0])
    }catch(e){
    [1,0,0]
    }

    Or maybe you could have an invisible layer that isn’t scaled parented to the layer that is scaled and get the x vector from the one that isn’t scaled. It depends on what your situation is.

Page 74 of 1081

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