Copy link to clipboard
Copied
how do i make this work i found online it dont seem to remove it when i click it.
i added auto color on a layer and clicked and press the button it don't remove it.
/**
*Script removes defined effect from the selected compositions
*/
var mainWindow = new Window("palette", "Remove Effect", undefined); // main frame, column
mainWindow.orientation = "column";
var inputTextGroup = mainWindow.add("group", undefined, "Input Text Group"); // first group, row
inputTextGroup.orientation = "row";
var textInput = inputTextGroup.add("edittext", undefined, "ADBE AutoColor");
textInput.size = [100, 25];
var buttonGroup = mainWindow.add("group", undefined, "Button Group");
buttonGroup.orientation = "row";
var removeButton = buttonGroup.add("button", undefined, "Remove Effect");
removeButton.size = [100, 25];
mainWindow.center();
mainWindow.show();
removeButton.onClick = function (){
app.beginUndoGroup("Remove Effect");
var effectName = textInput.text;
//Work with selected compositions only
for (var k = 1; k <= app.project.numItems; k++){
if ((app.project.item(k) instanceof CompItem) && app.project.item(k).selected) {
var myLayers = app.project.item(k).layers;
for (var i = 1; i <= myLayers.length; i ++) {
var CurrLayer = app.project.item(k).layer(i); // select curr layer
// 1. Remove effect
if (CurrLayer.Effects.property(effectName)){
CurrLayer.Effects.property(effectName).remove(); // removes selected effect
}
}
}
}
// app.executeCommand(app.findMenuCommandId("Save a Copy As...")); // uncomment to save if needed
app.endUndoGroup();
}
Copy link to clipboard
Copied
does this look ok it seems to work on selected layer.
if you think you can make it better please share.
one issue now is when i try and remove slider control i get error on extend script null is not an object
ADBE Slider Control < throws this error when i use this.
but if i use ADBE AutoColor to remove auto color it works no errors
var thisComp = app.project.activeItem;
var hasEffect = false;
var thisLayer = thisComp.selectedLayers[0];
var shapeGroupCollection = thisLayer.property(2);
var comp = app.project.activeItem;
var selectedLayers = comp.selectedLayers;
var layer = comp.selectedLayers[0];
//for (var i = 0; i < selectedLayers.length; i++) {
for (var i = 1; i <= layer.property("Effects").numProperties; i++) {
//selectedLayers[i].selected = false;
//layer.property("Effects").property("ADBE AutoColor").remove();
layer.property("Effects").property("ADBE Slider Control").remove();
}
Copy link to clipboard
Copied
Your code has several problems.
First, if several effect need to be deleted on the same layer, it won't delete all of them. You go over the effects from first to last. If you now delete the first effect, the second one will become the first one and then your code won't check this second effect, which has now become the first one.
To solve this, you could go backwards over the effects:
for (var i = layer.property("Effects").numProperties; i >= 1; i--)
Second issue: you loop over the effects with the variable i, but inside the loop you don't look at effect number i. Either you look at effect number i, check its match name and if it is the one you are looking for, delete it. Or even simpler, you use a while loop, to repeat the delete as long as such an effect exists:
With Automation Blocks, the code to delete all slider control effects on the selected layers with a for loop looks like this:
And the variant with while would be
Also note that Automation Blocks comes with an ready to use example "Delete All Occurrences of Effect", which asks for a search word and then deletes all effects whose name contains this search word:
Cheers
Mathias
Copy link to clipboard
Copied
Mathias thank you for taking the time to share your excellent post.
can you kindly show me an example of how to remove a specific effect using a string rather than removing all the controls this could be problematic at some point when working on live projects as it may contain controls already assigned to other comps+controls?
please kindly share how to remove effect using a custom string name
slider control name = speed
now remove all slider that contains the string speed.
with one example i can play and learn further thank you Mathias
Copy link to clipboard
Copied
am building a custom script for my use and I don't want to download 3rd party as I cant use it in my script.
am making all in one tool so all the shortcut I need is being added to the script am making.
Copy link to clipboard
Copied
once its done i will share it with you and public
Copy link to clipboard
Copied
while loop works flawlessly lol.
is it possible to remove control + effects using custom strings as we rename the effects and controls sir.
Copy link to clipboard
Copied
Yes, you can simply use the the name you gave the slider instead of the matchname. This removes all effects which you named "speed":
Copy link to clipboard
Copied
bro Mathias i se that while loop stays running unlimited time so it can be problem unless we can stop it ?
also can you share a code how to remove using custom string.
i am testing your script and i am unable to remove a slider using string name also?
Copy link to clipboard
Copied
bug with your script.
cant close when i press red x.
when i try delete a effect from library nothing happens
Copy link to clipboard
Copied
had to uninstall it as it started to crash my after effects 2022 on startup always now.
Copy link to clipboard
Copied
I guess you renamed the "Speed" in only one of the two occurrences of the script? If you do that, it loops forever, of course.
Copy link to clipboard
Copied
sir the do-while is open and it is on a continuous loop which will choke after-effects and freeze it.
this needs to be modified so it stops after sometime of checking all controls are gone.
while(layer.property("Effects").property("Speed")){
layer.property("Effects").property("Speed").remove();
}
Copy link to clipboard
Copied
it does such a check:
layer.property("Effects").property("Speed")
will evaluate to false as soon as there does not exist a property "Speed" in the Effects of the layer anymore and that should stop the while loop.