• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

please help fix this code after effects extendscript

Explorer ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

am trying to make this code work on selected layer how ever sometimes it ends up removing all control sliders for the top layer.

 

my goal is to use this in a button i have i tested but the code is buggy.

i need it fixed so that it works on selected layer.

am trying to remove all control sliders or specific slider with name.

 

var myLayer = app.project.activeItem.layer(1);
var hasEffect = false;
var targetComp = app.project.activeItem.selectedLayers; // Collect the active composition
var selectedLayer = targetComp.selectedLayers; // Collect the selected layers
var comp = app.project.activeItem;
var layer = comp.selectedLayers[0];
function doesithaveit(){
//for (var i = 1; i <= myLayer.property("Effects").numProperties; i++) {
for (var i = 1; i <= layer.property("Effects").numProperties; i++) {
if (layer.property("Effects").property(i).matchName == "ADBE Slider Control") {
layer.property("Effects").property(i).remove(); 
hasEffect = true;

}
      //  alert("It does!");
      if (!hasEffect) {
    doesithaveit();
}
      
      // break;
    }
}
button13.onClick = function () {
doesithaveit();
}

 

TOPICS
Expressions , Scripting

Views

99

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 06, 2022 Jul 06, 2022

Copy link to clipboard

Copied

LATEST

var matchNames = ["ADBE Slider Control", "ADBE Angle Control"];
//Add your desired matchName as an element of this array

removeControl();
function removeControl(){

        app.beginUndoGroup("Remove Control");

        var comp = app.project.activeItem;
        var layers = comp.selectedLayers;
        // All of the selected layers in this composition. This is a 0-based array (the first object is at index 0).
        
        for(var i=0; i < layers.length; i++){
        //Execute the command below repeatedly for the selected number of layers.
        
                var layer = layers[i];
                var effects = layer.property("ADBE Effect Parade"); // "Effects" match name
        
                for(var num=effects.numProperties; num > 0; num--){ //When an effect control is removed, the total count also changes, so you must remove them in reverse order.
        
                        var effect = effects.property(num);
                        var hasEffect = boolControlExistsAtEffects(effect.matchName);
        
                        if(hasEffect==true){ effect.remove() }
        
                }
        
        }

        app.endUndoGroup();

}

function boolControlExistsAtEffects(currentEffectMatchName){ //Returns true if it matches one of the elements in the matchNames array.

        var hasEffect = false;
        //Initialize the hasEffect variable to false.

        for(var f=0; f < matchNames.length; f++){

                if(currentEffectMatchName==matchNames[f]){
                //If matchName is matched, it assigns true to the hasEffect variable.
                hasEffect=true;
                }

        }

        //If no match is found, hasEffect will remain false.
        return hasEffect;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines