Skip to main content
TBNUK
Participant
January 10, 2019
Answered

Applying Transform Modification To All Open Comps On Specific Layer

  • January 10, 2019
  • 2 replies
  • 433 views

Hi All,

So I've got 100 comps that all need an opacity adjustment from 80% to 60% on Layer 10 of all the compositions.

Is there a script I can run that will automatically adjust the opacity value of layer 10, to 60% on all open/active compositions?

Would save loads of time copy and pasting the opacity value on to all 100 comps.

Thanks,

SAM

Running AE 2018 on PC if that's any help.

This topic has been closed for replies.
Correct answer Tomas Sinkunas

Hey Sam. Here's a small script that does what you need.

To make it work, you'll have to select bunch of compositions in project panel first, since there's no way to get open comps in AE, and there can only be one active composition.

Anyways, hope this helps.

Feel free to change first free parameters to your needs. Cheers..

(function() {

    /*.  MODIFY THESE VALUES.  */

    var targetLayerIndex = 10;

    var targetProperty = "opacity"; // anchorPoint, position, scale, rotation, opacity

    var value = 80;

    // Get selected compositions

    var selectedComps = getSelectedComps();

    if (!selectedComps) {

        // Abort if no compositions are selected

        return alert('Please select some compositions');

    }

    app.beginUndoGroup("Set Value");

    var composition, layer, property;

    for (var i = 0, il = selectedComps.length; i < il; i++) {

        composition = selectedComps;

        if (composition.numLayers < targetLayerIndex) {

            // Target index exceeds number of layers in composition

            continue;

        }

        property = composition.layer(targetLayerIndex)[targetProperty];

        if (!property) {

            // Target layer does nt have requested property

            alert('Undefined property "' + targetProperty + '"');

        }

        if (property.numKeys > 0) {

            // If property contains keyframes, new value will be set at current composition time

            property.setValueAtTime(composition.time, value);

        } else {

            property.setValue(value);

        }

    }

    app.endUndoGroup();

    function getSelectedComps() {

        var compositions = [];

        var selection = app.project.selection;

        for (var i = 0, il = selection.length; i < il; i++) {

            if (selection instanceof CompItem) {

                compositions.push(selection);

            }

        }

        if (compositions.length === 0) {

            return null;

        }

        return compositions;

    }

})();

2 replies

Tomas Sinkunas
Tomas SinkunasCorrect answer
Legend
January 19, 2019

Hey Sam. Here's a small script that does what you need.

To make it work, you'll have to select bunch of compositions in project panel first, since there's no way to get open comps in AE, and there can only be one active composition.

Anyways, hope this helps.

Feel free to change first free parameters to your needs. Cheers..

(function() {

    /*.  MODIFY THESE VALUES.  */

    var targetLayerIndex = 10;

    var targetProperty = "opacity"; // anchorPoint, position, scale, rotation, opacity

    var value = 80;

    // Get selected compositions

    var selectedComps = getSelectedComps();

    if (!selectedComps) {

        // Abort if no compositions are selected

        return alert('Please select some compositions');

    }

    app.beginUndoGroup("Set Value");

    var composition, layer, property;

    for (var i = 0, il = selectedComps.length; i < il; i++) {

        composition = selectedComps;

        if (composition.numLayers < targetLayerIndex) {

            // Target index exceeds number of layers in composition

            continue;

        }

        property = composition.layer(targetLayerIndex)[targetProperty];

        if (!property) {

            // Target layer does nt have requested property

            alert('Undefined property "' + targetProperty + '"');

        }

        if (property.numKeys > 0) {

            // If property contains keyframes, new value will be set at current composition time

            property.setValueAtTime(composition.time, value);

        } else {

            property.setValue(value);

        }

    }

    app.endUndoGroup();

    function getSelectedComps() {

        var compositions = [];

        var selection = app.project.selection;

        for (var i = 0, il = selection.length; i < il; i++) {

            if (selection instanceof CompItem) {

                compositions.push(selection);

            }

        }

        if (compositions.length === 0) {

            return null;

        }

        return compositions;

    }

})();

TBNUK
TBNUKAuthor
Participant
January 21, 2019

Hi Tomas,

This works like a dream! Thanks so much for you help!

Massive time saver!

Much appreciated,

SAM

Rameez_Khan
Legend
January 18, 2019

Hi SAM,

I've moved your discussion to the scripting forum for better assistance.

Thanks,

Rameez