Page 1 of 1
Remove All Effects fro all Layers
Posted: April 24th, 2011, 2:48 pm
by taravasya
Hi! I try to create a script, which will delete(clear), all efects of all layer from current composition.
Code: Select all
{
var myComp = app.project.activeItem;
myLayers = myComp.layers;
for (var i = 1; i <= myLayers.length; i++)
{
myLayers[i].Effects.remove();
}
}
With this script, i have error:

Pleas help me!
Re: Remove All Effects fro all Layers
Posted: April 24th, 2011, 8:19 pm
by Dan Ebberts
It you're trying to remove the Effects property group rather than the individual effects. You might have more luck with this:
Code: Select all
{
var myComp = app.project.activeItem;
var myEffects;
for (var i = 1; i <= myComp.numLayers; i++){
try{
myEffects = myComp.layer(i).Effects;
for (j = myEffects.numProperties; j > 0; j--){
myEffects.property(j).remove();
}
}catch(err){
}
}
}
Dan
Re: Remove All Effects fro all Layers
Posted: April 25th, 2011, 10:11 am
by taravasya
Thanks Dan! It`s work perfect!!!
I think, I need else reset all settings, remove all keyframes and expressions on timeline from script....
Can you do this script?
Thanks again!
Re: Remove All Effects fro all Layers
Posted: April 25th, 2011, 10:20 am
by taravasya
Well... I found how I can remove all expressions:
Code: Select all
{
var comp = app.project.activeItem;
if ((comp != null) && (comp instanceof CompItem))
{
for (var i=1; i<comp.layers.length; i++)
{
recurse_children(comp.layers[i]);
}
app.endUndoGroup();
}
else
alert('no comp selected');
function recurse_children(propParent)
{
if (propParent != null)
{
var prop;
for (var i=1; i<=propParent.numProperties; i++)
{
prop = propParent.property(i);
switch (prop.propertyType)
{
case PropertyType.PROPERTY:
// do action
if (prop.canSetExpression && prop.expression) prop.expression = '';
break;
case PropertyType.INDEXED_GROUP:
recurse_children(prop);
break;
case PropertyType.NAMED_GROUP:
recurse_children(prop);
break;
default:
break;
}
}
}
}
}
It`s work!
Now I still need to reset settings and remove all keyframes.. (ofcause if it`s possible).