Forum Replies Created

Page 3 of 65
  • Andrei Popa

    October 25, 2023 at 6:32 am in reply to: Flexible scale

    If you want to keep the scale constant in comparison with the smallest measure of the comp (width/height), you could use this:

    value*Math.min(thisComp.width/1920, thisComp.height/1080)

    If you now change your comp to 1920×1920, the image remains the same. I would choose to stick with the smallest of the 2 measurements (width/height) so I am sure that the image is never larger than the actual comp

  • Andrei Popa

    October 6, 2023 at 12:37 pm in reply to: Move marker of a layer depending on its length

    You can’t move markers with expressions, but you can modify your expression so it does not need markers anymore. And it will also be faster to render. Somehting like this to replace the part that you posted should work

    startDur = 5;
    endDur = 15;
    startDur = framesToTime(startDur);
    endDur = framesToTime(endDur);
    if (numKeys > 0) {
    t = linear(time, inPoint + startDur, outPoint - endDur, key(1).time, key(numKeys).time);
    valueAtTime(t);
    } else

    You can modify the frist startDur and endDur to how many frames from beginning and end you want the animation to start.

    I dont know how the rest of your expression looks like to also modify that part.

  • I suggest you pass a parameter to your smet function, and don’t use global variables. This changes seem to make your code work:

    ....

    ok.onClick = function () {

    var numSl = parseInt(nSlice.text)

    smet(numSl);

    nW.hide();

    }

    function smet(numSl) {

    ...

    The rest of the code remains the same

  • Hi David.

    Here is a version that makes the script work correctly as panel.

    If you could give me a project in which the error is present, I could try to debug that.

    (function (thisObj) {
    var copyLastKeyframe = function (prop) {
    var numKeys = prop.numKeys;
    if (numKeys < 2) {
    alert("There must be at least two keyframes on the selected property.");
    return;
    }
    var lastKeyframeValue = prop.keyValue(numKeys);
    prop.setValueAtTime(prop.keyTime(numKeys - 1), lastKeyframeValue);
    prop.removeKey(numKeys);
    };
    var main = function () {
    var comp = app.project.activeItem;
    if (!(comp && comp instanceof CompItem)) {
    alert("Please select a composition.");
    return;
    }
    var selectedProps = comp.selectedProperties;
    if (selectedProps.length === 0) {
    alert("Please select at least one property to modify.");
    return;
    }
    app.beginUndoGroup("Jump KF");
    for (var i = 0, il = selectedProps.length; i < il; i++) {
    var prop = selectedProps[i];
    if (prop.propertyType === PropertyType.PROPERTY) {
    copyLastKeyframe(prop);
    } else if (prop.propertyType === PropertyType.INDEXED_GROUP || prop.propertyType === PropertyType.NAMED_GROUP) {
    for (var j = 1, jl = prop.numProperties; j <= jl; j++) {
    var subProp = prop.property(j);
    if (subProp.propertyType === PropertyType.PROPERTY) {
    copyLastKeyframe(subProp);
    }
    }
    }
    }
    app.endUndoGroup();
    };
    var dockableWindow = thisObj instanceof Panel ? thisObj : new Window("palette", "Jump KF", undefined, {
    resizeable: true,
    });
    var button = dockableWindow.add("button", undefined, "Jump KF");
    button.onClick = main;
    dockableWindow.layout.layout(true);
    dockableWindow.layout.resize();
    dockableWindow.onResizing = dockableWindow.onResize = function () {
    this.layout.resize();
    };
    if (dockableWindow instanceof Panel) {
    dockableWindow.layout.layout(true);
    dockableWindow.layout.resize();
    } else {
    dockableWindow.center();
    dockableWindow.show();
    }
    })(this);
  • The closest thing I can think of is essential graphics. Create essential graphics using the comp in which the drop shadow is as main comp. Add the drop shadow distance(and any other property that you want to modify). Where you use the comp as layer, select it and press “u” twice. On essential property distance, put an expression that also includes the scale. Smething like

    value * transform.scale[1] * 0.01
  • Well, since you are building this toolkit, I think you have the data for this expression. You need the duration of the in-out animation.

    Then apply this to the time-remap property:

    inDur = 1;
    outDur = 1;
    myMarker = marker.key(1);
    if (time > myMarker.time - outDur) {
    linear(
    time,
    myMarker.time - outDur,
    myMarker.time,
    key(2).time - inPoint - outDur,
    key(2).time - inPoint
    );
    } else {
    linear(time, inPoint, inPoint + inDur, 0, inDur);
    }

    However, I would do it different. You can use the following expression, and just cut the layer where you want it to end. And the animation will follow the out-point of the layer:

    inDur = 1;
    outDur = 1;
    if (time > outPoint - outDur) {
    linear(
    time,
    outPoint - outDur,
    outPoint,
    key(2).time - inPoint - outDur,
    key(2).time - inPoint
    );
    } else {
    linear(time, inPoint, inPoint + inDur, 0, inDur);
    }
  • I think you want to give last value and easing to previous key and delete the last key. I made some changes, but did not test them.

    var activeComp = app.project.activeItem;
    if (activeComp == null || !(activeComp instanceof CompItem)) {
    alert("Please select a composition first.");
    } else {
    var selectedLayer = activeComp.selectedLayers[0];
    if (selectedLayer == null) {
    alert("Please select a layer first.");
    } else {
    var selectedProperty = selectedLayer.selectedProperties[0];
    if (selectedProperty == null) {
    alert("Please select a property first.");
    } else if (selectedProperty.numKeys < 2) {
    alert("Property must have at least 2 keyframes.");
    } else {
    var lastKeyframeIndex = selectedProperty.numKeys;
    var secondToLastKeyframeIndex = selectedProperty.numKeys - 1;
    // Store the last keyframe value and temporal ease
    var lastValue = selectedProperty.keyValue(lastKeyframeIndex);
    var lastInEase = selectedProperty.keyInTemporalEase(lastKeyframeIndex);
    var lastOutEase = selectedProperty.keyOutTemporalEase(lastKeyframeIndex);
    //set last value to previous key
    selectedProperty.setValueAtKey(secondToLastKeyframeIndex, lastValue);
    //set last ease to previous key
    secondToLastKeyframe.setTemporalEaseAtKey(secondToLastKeyframeIndex, lastInEase, lastOutEase);
    // Remove the last keyframe
    selectedProperty.removeKey(lastKeyframeIndex);
    }
    }
    }

  • Andrei Popa

    February 6, 2023 at 7:53 am in reply to: Reset next text horizontal scale

    I am using the first part of your script and it works fine(Adobe After Effects 2022 and 2023). Text gets to 0.5 and the horizontal scale does not change for the next layer I am creating. Maybe the horizontal scale was set to 0.5 before you ran the script.

    However, some error that I see in your code is that you create a text layer with the variable name “fixCharacter” and then try to use it with “fixCharText”.

  • Andrei Popa

    January 26, 2023 at 10:41 am in reply to: Can I get the color of a solid via expression?

    Thanks. I was trying not to use sampleImage() because AFAIK its quite slow, similar to sourceRectAtTime().

  • Andrei Popa

    January 18, 2023 at 11:37 am in reply to: Need somebody to develop a scrip to change comp length

    In the last line, 10 is how many frames you want per char. 10 chars for 1 seconds in 30 fps would be 3.

    Here are 3 functions that should help you out. You can modify the options object (everything that is between {}) to your needs.

    var options = {
    fadeToBlackLayerIndex: 2,
    fadeOutSoundLayerIndex: 4,
    duration: 1,
    comp: app.project.activeItem,
    framesPerChar:3
    };
    app.beginUndoGroup("modify composition");
    setCompLength(options);
    fadeToBlack(options);
    fadeOutSound(options);
    app.endUndoGroup();
    function fadeToBlack(options) {
    var comp = options.comp;
    var duration = options.duration;
    var layerIndex = options.fadeToBlackLayerIndex;
    var layer = comp.layer(layerIndex);
    layer.opacity.setValueAtTime(comp.duration - duration, layer.opacity.valueAtTime(comp.duration - duration, false));
    layer.opacity.setValueAtTime(comp.duration, 0);
    }
    function fadeOutSound(options) {
    var layerIndex = options.fadeOutSoundLayerIndex;
    var comp = options.comp;
    var duration = options.duration;
    var layer = comp.layer(layerIndex);
    layer.audio.audioLevels.setValueAtTime(comp.duration - duration, layer.audio.audioLevels.valueAtTime(comp.duration - duration, false));
    layer.audio.audioLevels.setValueAtTime(comp.duration, [-40, -40]);
    }
    function setCompLength(options) {
    var myComp = options.comp;
    var framesPerChar = options.framesPerChar;
    //search first text layer and save character number
    for (var i = 1; i <= myComp.numLayers; i++) {
    var crtLayer = myComp.layer(i);
    if (crtLayer instanceof TextLayer) {
    var numChars = crtLayer.text.sourceText.value.text.length;
    break;
    }
    }
    myComp.duration = framesPerChar * myComp.frameDuration * numChars;
    }
Page 3 of 65

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