Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Duplicate Layer with Layer Control Property

  • Duplicate Layer with Layer Control Property

    Posted by Nils Hammers on March 11, 2024 at 2:42 pm

    Is there a way to duplicate a layer so, that the Effects with Layer property that points to the very same layer is duplicated with self-reference?
    The regular duplicates maintain the original setting. E.g. when using CC Composite, you’d likely to point to the same layer – unfortunately, this cannot be scripted with thisLayer, and invoking the every CC Composite instance in 50+ copies comp, where duplication might need re-iteration, seems a problem.

    Nils Hammers replied 2 years, 2 months ago 1 Member · 1 Reply
  • 1 Reply
  • Nils Hammers

    March 15, 2024 at 1:14 pm

    My first attempt, yet I managed to concoct some kind of working script that solves this, apparently, a duplication bug in 6421 control.

    function cloneLayers(num_of_copies, keep_selfref, move_after) {
    app.beginUndoGroup("Clone Selected Layer(s)") ;
    var comp = app.project.activeItem ;
    if (comp && comp instanceof CompItem) {
    var selection = comp.selectedLayers ;
    if ( selection.length > 0 ) {
    for (var i = 0; i < selection.length; i++ ) {
    var selectedLayer = selection[i] ;
    var cloningData = [] ;
    var effectGroup = selectedLayer.property("ADBE Effect Parade") ;
    for (var j = 1; j <= effectGroup.numProperties; j++) {
    var effect = effectGroup.property(j) ;
    for (var k = 1; k <= effect.numProperties; k++) {
    var property = effect.property(k) ;
    if (property.propertyValueType == 6421 && selectedLayer.index == property.value) {
    cloningData.push([j, k]) ;
    }
    }
    }
    // Cloning
    for(var n = 0; n < num_of_copies; n++) {
    var clone = selectedLayer.duplicate() ;
    move_after ? clone.moveAfter(selectedLayer) : void(0);
    if (keep_selfref) {
    for (var m = 0; m < cloningData.length; m++) {
    var cd = cloningData[m] ;
    clone.property("ADBE Effect Parade").property(cd[0]).property(cd[1]).setValue(clone.index) ;
    }
    }
    }
    }
    } else {
    alert("No selected layer.");
    }
    } else {
    alert("No active composition.");
    }
    app.endUndoGroup() ;
    }

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